sea-chart 0.0.20 → 0.0.22
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/constants/index.js +4 -1
- package/dist/locale/lang/de.js +4 -1
- package/dist/locale/lang/en.js +6 -1
- package/dist/locale/lang/es.js +4 -1
- package/dist/locale/lang/fr.js +4 -1
- package/dist/locale/lang/pt.js +4 -1
- package/dist/locale/lang/ru.js +4 -1
- package/dist/locale/lang/zh_CN.js +9 -4
- package/dist/model/area-group.js +4 -2
- package/dist/model/area.js +3 -2
- package/dist/model/basic-number-card.js +5 -1
- package/dist/model/line-group.js +3 -2
- package/dist/model/line.js +3 -2
- package/dist/settings/advance-bar-settings/style-settings.js +8 -2
- package/dist/settings/bar-settings/style-settings.js +10 -3
- package/dist/settings/basic-number-card/style-settings.js +48 -3
- package/dist/settings/widgets/select-line-type/index.css +0 -0
- package/dist/settings/widgets/select-line-type/index.js +27 -0
- package/dist/view/wrapper/area.js +75 -32
- package/dist/view/wrapper/basic-number-card.js +6 -33
- package/dist/view/wrapper/chart-component.js +49 -3
- package/dist/view/wrapper/horizontal-bar.js +2 -7
- package/dist/view/wrapper/line-group.js +62 -46
- package/dist/view/wrapper/line.js +67 -62
- package/package.json +1 -1
package/dist/constants/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export const ZH_CN_SUPPORT_CHARTS = [CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE];
|
|
|
14
14
|
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.AREA, CHART_TYPE.TREE_MAP];
|
|
15
15
|
export const SUPPORT_STACK_VALUE_CHART_TYPES = [CHART_TYPE.BAR_STACK, CHART_TYPE.BAR_CUSTOM];
|
|
16
16
|
export const X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES = [CHART_TYPE.TABLE, CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TREE_MAP];
|
|
17
|
-
export const SUPPORT_TITLE_CHART_TYPES = [CHART_TYPE.BAR, CHART_TYPE.BAR_GROUP, CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.COMPLETENESS, CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.COMBINATION, CHART_TYPE.DASHBOARD, CHART_TYPE.TREE_MAP, CHART_TYPE.TABLE, CHART_TYPE.BAR_CUSTOM];
|
|
17
|
+
export const SUPPORT_TITLE_CHART_TYPES = [CHART_TYPE.BAR, CHART_TYPE.BAR_GROUP, CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.COMPLETENESS, CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.COMBINATION, CHART_TYPE.DASHBOARD, CHART_TYPE.TREE_MAP, CHART_TYPE.TABLE, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP];
|
|
18
18
|
export const CHART_CHART_MAP = {
|
|
19
19
|
[CHART_TYPE.BAR]: CHART_TYPE.BAR,
|
|
20
20
|
[CHART_TYPE.PIE]: CHART_TYPE.PIE,
|
|
@@ -74,6 +74,9 @@ export const CHART_DATA_SORT_TYPE = {
|
|
|
74
74
|
ASCENDING: 'ascending',
|
|
75
75
|
DESCENDING: 'descending'
|
|
76
76
|
};
|
|
77
|
+
const POLYLINES = 'polylines';
|
|
78
|
+
const CURVES = 'curves';
|
|
79
|
+
export const CHART_LINE_TYPES = [POLYLINES, CURVES];
|
|
77
80
|
export const CHART_DATA_SORT_TYPES = [CHART_DATA_SORT_TYPE.NOT_SORTED, CHART_DATA_SORT_TYPE.ASCENDING, CHART_DATA_SORT_TYPE.DESCENDING];
|
|
78
81
|
export const CHART_DATA_SORT_TYPE_SHOW = {
|
|
79
82
|
[CHART_DATA_SORT_TYPE.NOT_SORTED]: 'Not_sorted',
|
package/dist/locale/lang/de.js
CHANGED
|
@@ -162,6 +162,9 @@ const de = {
|
|
|
162
162
|
'Numeric_column_not_found': 'Numeric column not found',
|
|
163
163
|
'Target_column_not_found': 'Target column not found',
|
|
164
164
|
'Completed_column_not_found': 'Completed column not found',
|
|
165
|
-
'Target_summary_method_is_not_valid': 'Target summary method is not valid'
|
|
165
|
+
'Target_summary_method_is_not_valid': 'Target summary method is not valid',
|
|
166
|
+
'polylines': 'Polylines',
|
|
167
|
+
'curves': 'Curves',
|
|
168
|
+
'Line_type': 'Line type'
|
|
166
169
|
};
|
|
167
170
|
export default de;
|
package/dist/locale/lang/en.js
CHANGED
|
@@ -237,6 +237,11 @@ const en = {
|
|
|
237
237
|
"Previous_7_days": "Previous 7 days",
|
|
238
238
|
"Previous_30_days": "Previous 30 days",
|
|
239
239
|
"The_day_before_yesterday": "The day before yesterday",
|
|
240
|
-
"Can_not_compare_with_{var}": "Can not compare with {var}"
|
|
240
|
+
"Can_not_compare_with_{var}": "Can not compare with {var}",
|
|
241
|
+
"Number_settings": "Number settings",
|
|
242
|
+
"Label_settings": "Label settings",
|
|
243
|
+
'polylines': 'Polylines',
|
|
244
|
+
'curves': 'Curves',
|
|
245
|
+
'Line_type': 'Line type'
|
|
241
246
|
};
|
|
242
247
|
export default en;
|
package/dist/locale/lang/es.js
CHANGED
|
@@ -162,6 +162,9 @@ const es = {
|
|
|
162
162
|
'Numeric_column_not_found': 'Numeric column not found',
|
|
163
163
|
'Target_column_not_found': 'Target column not found',
|
|
164
164
|
'Completed_column_not_found': 'Completed column not found',
|
|
165
|
-
'Target_summary_method_is_not_valid': 'Target summary method is not valid'
|
|
165
|
+
'Target_summary_method_is_not_valid': 'Target summary method is not valid',
|
|
166
|
+
'polylines': 'Polylines',
|
|
167
|
+
'curves': 'Curves',
|
|
168
|
+
'Line_type': 'Line type'
|
|
166
169
|
};
|
|
167
170
|
export default es;
|
package/dist/locale/lang/fr.js
CHANGED
|
@@ -162,6 +162,9 @@ const fr = {
|
|
|
162
162
|
'Numeric_column_not_found': 'Numeric column not found',
|
|
163
163
|
'Target_column_not_found': 'Target column not found',
|
|
164
164
|
'Completed_column_not_found': 'Completed column not found',
|
|
165
|
-
'Target_summary_method_is_not_valid': 'Target summary method is not valid'
|
|
165
|
+
'Target_summary_method_is_not_valid': 'Target summary method is not valid',
|
|
166
|
+
'polylines': 'Polylines',
|
|
167
|
+
'curves': 'Curves',
|
|
168
|
+
'Line_type': 'Line type'
|
|
166
169
|
};
|
|
167
170
|
export default fr;
|
package/dist/locale/lang/pt.js
CHANGED
|
@@ -162,6 +162,9 @@ const pt = {
|
|
|
162
162
|
'Numeric_column_not_found': 'Numeric column not found',
|
|
163
163
|
'Target_column_not_found': 'Target column not found',
|
|
164
164
|
'Completed_column_not_found': 'Completed column not found',
|
|
165
|
-
'Target_summary_method_is_not_valid': 'Target summary method is not valid'
|
|
165
|
+
'Target_summary_method_is_not_valid': 'Target summary method is not valid',
|
|
166
|
+
'polylines': 'Polylines',
|
|
167
|
+
'curves': 'Curves',
|
|
168
|
+
'Line_type': 'Line type'
|
|
166
169
|
};
|
|
167
170
|
export default pt;
|
package/dist/locale/lang/ru.js
CHANGED
|
@@ -162,6 +162,9 @@ const ru = {
|
|
|
162
162
|
'Numeric_column_not_found': 'Numeric column not found',
|
|
163
163
|
'Target_column_not_found': 'Target column not found',
|
|
164
164
|
'Completed_column_not_found': 'Completed column not found',
|
|
165
|
-
'Target_summary_method_is_not_valid': 'Target summary method is not valid'
|
|
165
|
+
'Target_summary_method_is_not_valid': 'Target summary method is not valid',
|
|
166
|
+
'polylines': 'Polylines',
|
|
167
|
+
'curves': 'Curves',
|
|
168
|
+
'Line_type': 'Line type'
|
|
166
169
|
};
|
|
167
170
|
export default ru;
|
|
@@ -105,9 +105,9 @@ const zh_CN = {
|
|
|
105
105
|
"Stacked_bar_chart": "堆叠条形图",
|
|
106
106
|
"Completeness": "完成度图",
|
|
107
107
|
"Grouped_completeness": "分组完成度图",
|
|
108
|
-
"Line_chart": "
|
|
109
|
-
"Basic_line_chart": "
|
|
110
|
-
"Grouped_line_chart": "
|
|
108
|
+
"Line_chart": "线型图",
|
|
109
|
+
"Basic_line_chart": "基础线型图",
|
|
110
|
+
"Grouped_line_chart": "分组线型图",
|
|
111
111
|
"Area": "面积图",
|
|
112
112
|
"Grouped_area": "分组面积图",
|
|
113
113
|
"Pie_chart": "饼图",
|
|
@@ -237,6 +237,11 @@ const zh_CN = {
|
|
|
237
237
|
"Previous_7_days": "之前 7 天",
|
|
238
238
|
"Previous_30_days": "之前 30 天",
|
|
239
239
|
"The_day_before_yesterday": "前天",
|
|
240
|
-
"Can_not_compare_with_{var}": "无法和 {var} 比较"
|
|
240
|
+
"Can_not_compare_with_{var}": "无法和 {var} 比较",
|
|
241
|
+
"Number_settings": "数字设置",
|
|
242
|
+
"Label_settings": "标签设置",
|
|
243
|
+
'polylines': '折线',
|
|
244
|
+
'curves': '曲线',
|
|
245
|
+
'Line_type': '线型'
|
|
241
246
|
};
|
|
242
247
|
export default zh_CN;
|
package/dist/model/area-group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseModel from './base-model';
|
|
2
1
|
import { isBoolean } from '../utils';
|
|
3
|
-
import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
|
|
2
|
+
import { CHART_TYPE, CHART_SUMMARY_TYPE, CHART_LINE_TYPES } from '../constants';
|
|
3
|
+
import BaseModel from './base-model';
|
|
4
4
|
class AreaGroup extends BaseModel {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
super({
|
|
@@ -36,6 +36,8 @@ class AreaGroup extends BaseModel {
|
|
|
36
36
|
this.summary_columns = options.summary_columns;
|
|
37
37
|
this.y_axis_use_stack = options.y_axis_use_stack;
|
|
38
38
|
this.label_font_size = options.label_font_size;
|
|
39
|
+
// default as curve
|
|
40
|
+
this.line_type = options.line_type || CHART_LINE_TYPES[1];
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
export default AreaGroup;
|
package/dist/model/area.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseModel from './base-model';
|
|
2
1
|
import { isBoolean } from '../utils';
|
|
3
|
-
import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
|
|
2
|
+
import { CHART_TYPE, CHART_SUMMARY_TYPE, CHART_LINE_TYPES } from '../constants';
|
|
3
|
+
import BaseModel from './base-model';
|
|
4
4
|
class Area extends BaseModel {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
super({
|
|
@@ -27,6 +27,7 @@ class Area extends BaseModel {
|
|
|
27
27
|
this.y_axis_label_color = options.y_axis_label_color;
|
|
28
28
|
this.sort_type = options.sort_type;
|
|
29
29
|
this.label_font_size = options.label_font_size;
|
|
30
|
+
this.line_type = options.line_type || CHART_LINE_TYPES[1];
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
export default Area;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumericColumn, getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
-
import BaseModel from './base-model';
|
|
3
2
|
import { CHART_SUMMARY_TYPE, CHART_TYPE } from '../constants';
|
|
3
|
+
import BaseModel from './base-model';
|
|
4
4
|
class BasicNumberCard extends BaseModel {
|
|
5
5
|
constructor(options, tables) {
|
|
6
6
|
super({
|
|
@@ -17,6 +17,10 @@ class BasicNumberCard extends BaseModel {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
this.summary_method = options.y_axis_summary_method || CHART_SUMMARY_TYPE.ROW_COUNT;
|
|
20
|
+
this.font_size = options.font_size || 40;
|
|
21
|
+
this.font_color = options.font_color;
|
|
22
|
+
this.label_font_size = options.label_font_size || 12;
|
|
23
|
+
this.label_font_color = options.label_font_color;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
export default BasicNumberCard;
|
package/dist/model/line-group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseModel from './base-model';
|
|
2
1
|
import { isBoolean } from '../utils';
|
|
3
|
-
import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
|
|
2
|
+
import { CHART_TYPE, CHART_SUMMARY_TYPE, CHART_LINE_TYPES } from '../constants';
|
|
3
|
+
import BaseModel from './base-model';
|
|
4
4
|
class LineGroup extends BaseModel {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
super({
|
|
@@ -39,6 +39,7 @@ class LineGroup extends BaseModel {
|
|
|
39
39
|
this.column_groupby_multiple_numeric_column = isBoolean(options.column_groupby_multiple_numeric_column) ? options.column_groupby_multiple_numeric_column : false;
|
|
40
40
|
this.summary_columns = options.summary_columns;
|
|
41
41
|
this.label_font_size = options.label_font_size;
|
|
42
|
+
this.line_type = options.line_type || CHART_LINE_TYPES[1];
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
export default LineGroup;
|
package/dist/model/line.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseModel from './base-model';
|
|
2
1
|
import { isBoolean } from '../utils';
|
|
3
|
-
import { CHART_TYPE, CHART_SUMMARY_TYPE } from '../constants';
|
|
2
|
+
import { CHART_TYPE, CHART_SUMMARY_TYPE, CHART_LINE_TYPES } from '../constants';
|
|
3
|
+
import BaseModel from './base-model';
|
|
4
4
|
class Line extends BaseModel {
|
|
5
5
|
constructor(options) {
|
|
6
6
|
super({
|
|
@@ -33,6 +33,7 @@ class Line extends BaseModel {
|
|
|
33
33
|
this.y_axis_label_color = options.y_axis_label_color;
|
|
34
34
|
this.sort_type = options.sort_type;
|
|
35
35
|
this.label_font_size = options.label_font_size;
|
|
36
|
+
this.line_type = options.line_type || CHART_LINE_TYPES[1];
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
export default Line;
|
|
@@ -9,6 +9,7 @@ import DisplayValuesSettings from '../widgets/display-values-settings';
|
|
|
9
9
|
import { eventStopPropagation } from '../../utils';
|
|
10
10
|
import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW, SUPPORT_STACK_VALUE_CHART_TYPES, CHART_TYPE } from '../../constants';
|
|
11
11
|
import intl from '../../intl';
|
|
12
|
+
import SelectLineType from '../widgets/select-line-type';
|
|
12
13
|
const StyleSettings = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
chart,
|
|
@@ -138,11 +139,16 @@ const StyleSettings = _ref => {
|
|
|
138
139
|
y_axis_max,
|
|
139
140
|
y_axis_show_value,
|
|
140
141
|
label_font_size,
|
|
141
|
-
display_each_block_data
|
|
142
|
+
display_each_block_data,
|
|
143
|
+
line_type
|
|
142
144
|
} = config;
|
|
143
145
|
const xAxisLabelPosition = xAxisLabelOptions.find(option => option.value === x_axis_label_position) || xAxisLabelOptions[0];
|
|
144
146
|
const yAxisLabelPosition = yAxisLabelOptions.find(option => option.value === y_axis_label_position) || yAxisLabelOptions[0];
|
|
145
|
-
|
|
147
|
+
const isLineChart = [CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP].includes(type);
|
|
148
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isLineChart && /*#__PURE__*/React.createElement(SelectLineType, {
|
|
149
|
+
selectedLineType: line_type,
|
|
150
|
+
onChange: onChange
|
|
151
|
+
}), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
|
|
146
152
|
className: "sea-chart-parameter-item"
|
|
147
153
|
}, /*#__PURE__*/React.createElement(Label, null, intl.get(xLabel)), /*#__PURE__*/React.createElement(Switch, {
|
|
148
154
|
key: "x_axis_show_label",
|
|
@@ -7,8 +7,9 @@ import MinMaxSetting from '../widgets/min-max-setting';
|
|
|
7
7
|
import DisplayValuesSettings from '../widgets/display-values-settings';
|
|
8
8
|
import ColorUseTypeSelector from '../widgets/color-settings/color-use-type-selector';
|
|
9
9
|
import { eventStopPropagation } from '../../utils';
|
|
10
|
-
import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW } from '../../constants';
|
|
10
|
+
import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW, CHART_TYPE } from '../../constants';
|
|
11
11
|
import intl from '../../intl';
|
|
12
|
+
import SelectLineType from '../widgets/select-line-type';
|
|
12
13
|
const StyleSettings = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
chart,
|
|
@@ -128,11 +129,17 @@ const StyleSettings = _ref => {
|
|
|
128
129
|
y_axis_min,
|
|
129
130
|
y_axis_max,
|
|
130
131
|
y_axis_show_value,
|
|
131
|
-
label_font_size
|
|
132
|
+
label_font_size,
|
|
133
|
+
type,
|
|
134
|
+
line_type
|
|
132
135
|
} = config;
|
|
133
136
|
const xAxisLabelPosition = xAxisLabelOptions.find(option => option.value === x_axis_label_position) || xAxisLabelOptions[0];
|
|
134
137
|
const yAxisLabelPosition = yAxisLabelOptions.find(option => option.value === y_axis_label_position) || yAxisLabelOptions[0];
|
|
135
|
-
|
|
138
|
+
const isLineChart = [CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP].includes(type);
|
|
139
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isLineChart && /*#__PURE__*/React.createElement(SelectLineType, {
|
|
140
|
+
selectedLineType: line_type,
|
|
141
|
+
onChange: onChange
|
|
142
|
+
}), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
|
|
136
143
|
className: "sea-chart-parameter-item"
|
|
137
144
|
}, /*#__PURE__*/React.createElement(Label, null, intl.get(xLabel)), /*#__PURE__*/React.createElement(Switch, {
|
|
138
145
|
key: "x_axis_show_label",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import { Input, FormGroup } from 'reactstrap';
|
|
2
|
+
import { Input, FormGroup, Label } from 'reactstrap';
|
|
3
|
+
import { FontSizeSettings, FontColorSettings } from '../widgets/font-settings';
|
|
4
|
+
import Divider from '../widgets/divider';
|
|
3
5
|
import intl from '../../intl';
|
|
6
|
+
import { DEFAULT_CHART_TITLE_FONT_COLOR } from '../../constants';
|
|
4
7
|
const StyleSettings = _ref => {
|
|
5
8
|
let {
|
|
6
9
|
chart,
|
|
@@ -25,18 +28,60 @@ const StyleSettings = _ref => {
|
|
|
25
28
|
e.target.blur();
|
|
26
29
|
}
|
|
27
30
|
}, []);
|
|
31
|
+
const modifyFontSize = (updatedFontSize, key) => {
|
|
32
|
+
onChange({
|
|
33
|
+
[key]: updatedFontSize
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const modifyFontColor = (updatedFontColor, key) => {
|
|
37
|
+
onChange({
|
|
38
|
+
[key]: updatedFontColor
|
|
39
|
+
});
|
|
40
|
+
};
|
|
28
41
|
const {
|
|
29
42
|
config
|
|
30
43
|
} = chart;
|
|
31
|
-
|
|
44
|
+
const {
|
|
45
|
+
font_size,
|
|
46
|
+
font_color,
|
|
47
|
+
label_font_size,
|
|
48
|
+
label_font_color
|
|
49
|
+
} = config;
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Label, null, intl.get('Number_settings')), /*#__PURE__*/React.createElement(FontSizeSettings, {
|
|
51
|
+
fontSize: font_size,
|
|
52
|
+
defaultFontSize: 40,
|
|
53
|
+
modifyFontSize: updatedFontSize => {
|
|
54
|
+
modifyFontSize(updatedFontSize, 'font_size');
|
|
55
|
+
}
|
|
56
|
+
}), /*#__PURE__*/React.createElement(FontColorSettings, {
|
|
57
|
+
fontColor: font_color,
|
|
58
|
+
defaultFontColor: DEFAULT_CHART_TITLE_FONT_COLOR,
|
|
59
|
+
modifyFontColor: updatedFontColor => {
|
|
60
|
+
modifyFontColor(updatedFontColor, 'font_color');
|
|
61
|
+
}
|
|
62
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
63
|
+
className: "mt-4"
|
|
64
|
+
}), /*#__PURE__*/React.createElement(Label, null, intl.get('Label_settings')), /*#__PURE__*/React.createElement(FormGroup, {
|
|
32
65
|
className: "sea-chart-parameter-item"
|
|
33
|
-
}, /*#__PURE__*/React.createElement(
|
|
66
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get('Label')), /*#__PURE__*/React.createElement(Input, {
|
|
34
67
|
type: "text",
|
|
35
68
|
value: name,
|
|
36
69
|
placeholder: config.name || '',
|
|
37
70
|
onBlur: onSaveName,
|
|
38
71
|
onChange: onChangeName,
|
|
39
72
|
onKeyDown: onKeyDown
|
|
73
|
+
})), /*#__PURE__*/React.createElement(FontSizeSettings, {
|
|
74
|
+
fontSize: label_font_size,
|
|
75
|
+
defaultFontSize: 12,
|
|
76
|
+
modifyFontSize: updatedFontSize => {
|
|
77
|
+
modifyFontSize(updatedFontSize, 'label_font_size');
|
|
78
|
+
}
|
|
79
|
+
}), /*#__PURE__*/React.createElement(FontColorSettings, {
|
|
80
|
+
fontColor: label_font_color,
|
|
81
|
+
defaultFontColor: DEFAULT_CHART_TITLE_FONT_COLOR,
|
|
82
|
+
modifyFontColor: updatedFontColor => {
|
|
83
|
+
modifyFontColor(updatedFontColor, 'label_font_color');
|
|
84
|
+
}
|
|
40
85
|
}));
|
|
41
86
|
};
|
|
42
87
|
export default StyleSettings;
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormGroup, Label } from 'reactstrap';
|
|
3
|
+
import DTableRadio from "dtable-ui-component/lib/DTableRadio";
|
|
4
|
+
import { CHART_LINE_TYPES } from '../../../constants';
|
|
5
|
+
import intl from '../../../intl';
|
|
6
|
+
function SelectLineType(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
selectedLineType,
|
|
9
|
+
onChange
|
|
10
|
+
} = _ref;
|
|
11
|
+
const onChangeLineType = lineType => {
|
|
12
|
+
if (lineType === selectedLineType) return;
|
|
13
|
+
onChange && onChange({
|
|
14
|
+
line_type: lineType
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, null, intl.get('Line_type')), CHART_LINE_TYPES.map((lineType, index) => {
|
|
18
|
+
const isChecked = lineType === selectedLineType;
|
|
19
|
+
return /*#__PURE__*/React.createElement(DTableRadio, {
|
|
20
|
+
key: index,
|
|
21
|
+
isChecked: isChecked,
|
|
22
|
+
onCheckedChange: () => onChangeLineType(lineType),
|
|
23
|
+
label: intl.get(lineType)
|
|
24
|
+
});
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export default SelectLineType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
|
|
3
|
+
import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
|
|
4
4
|
import intl from '../../intl';
|
|
5
5
|
import { BaseUtils, isFunction } from '../../utils';
|
|
6
6
|
import ChartComponent from './chart-component';
|
|
@@ -64,10 +64,12 @@ class Area extends ChartComponent {
|
|
|
64
64
|
y_axis_summary_type,
|
|
65
65
|
y_axis_summary_method,
|
|
66
66
|
y_axis_label_color,
|
|
67
|
+
line_type,
|
|
67
68
|
y_axis_show_value,
|
|
68
69
|
label_font_size
|
|
69
70
|
} = chart.config;
|
|
70
71
|
const newData = this.getChartGroupData(data);
|
|
72
|
+
const isSmooth = line_type === CHART_LINE_TYPES[1];
|
|
71
73
|
let chartBarColor;
|
|
72
74
|
if (this.isGroupChart) {
|
|
73
75
|
chartBarColor = this.groupName;
|
|
@@ -93,62 +95,102 @@ class Area extends ChartComponent {
|
|
|
93
95
|
}
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
|
|
99
|
+
// line
|
|
100
|
+
const line = this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
98
101
|
style: {
|
|
99
102
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
100
|
-
fill:
|
|
103
|
+
fill: theme.labelColor
|
|
101
104
|
}
|
|
102
|
-
}).position('name*value').
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
style: {
|
|
108
|
-
stroke: null
|
|
109
|
-
}
|
|
105
|
+
}).position('name*value').animate({
|
|
106
|
+
appear: {
|
|
107
|
+
animation: 'fadeIn',
|
|
108
|
+
duration: 1000,
|
|
109
|
+
easing: 'easeLinear'
|
|
110
110
|
}
|
|
111
|
+
}).color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').tooltip(false).style({
|
|
112
|
+
lineWidth: 3,
|
|
113
|
+
opacity: 1
|
|
111
114
|
});
|
|
112
|
-
|
|
115
|
+
|
|
116
|
+
// point
|
|
117
|
+
let point;
|
|
118
|
+
if (y_axis_show_value) {
|
|
119
|
+
point = this.chart.point().animate({
|
|
120
|
+
appear: {
|
|
121
|
+
animation: 'fadeIn',
|
|
122
|
+
duration: 1000,
|
|
123
|
+
easing: 'easeLinear'
|
|
124
|
+
}
|
|
125
|
+
}).position('name*value').color(chartBarColor).shape('circle').size(4).style({
|
|
126
|
+
stroke: 0,
|
|
127
|
+
fillOpacity: 1
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const area = this.chart.area().position('name*value').animate({
|
|
131
|
+
appear: {
|
|
132
|
+
animation: 'fadeIn',
|
|
133
|
+
duration: 1000,
|
|
134
|
+
easing: 'easeLinear'
|
|
135
|
+
}
|
|
136
|
+
}).shape(isSmooth ? 'smooth' : 'area').color(chartBarColor).tooltip('group_name*name*value', (group_name, name, value) => {
|
|
113
137
|
return {
|
|
114
|
-
|
|
138
|
+
title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
115
139
|
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
116
|
-
|
|
140
|
+
name: group_name
|
|
117
141
|
};
|
|
142
|
+
}).style({
|
|
143
|
+
fillOpacity: 0.3
|
|
118
144
|
});
|
|
119
|
-
this.chart.tooltip({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
this.chart.on('tooltip:show', () => {
|
|
146
|
+
if (line.styleOption.cfg.opacity === 0.3) return;
|
|
147
|
+
line.style({
|
|
148
|
+
opacity: 0.3,
|
|
149
|
+
lineWidth: 3
|
|
150
|
+
});
|
|
151
|
+
area.style({
|
|
152
|
+
fillOpacity: 0.1
|
|
153
|
+
});
|
|
154
|
+
if (point) point.style({
|
|
155
|
+
fillOpacity: 0.3,
|
|
156
|
+
stroke: 0
|
|
157
|
+
});
|
|
158
|
+
this.chart.render();
|
|
159
|
+
});
|
|
160
|
+
this.chart.on('tooltip:hide', () => {
|
|
161
|
+
if (line.styleOption.cfg.opacity === 1) return;
|
|
162
|
+
line.style({
|
|
163
|
+
opacity: 1,
|
|
164
|
+
lineWidth: 3
|
|
165
|
+
});
|
|
166
|
+
area.style({
|
|
167
|
+
fillOpacity: 0.3
|
|
168
|
+
});
|
|
169
|
+
if (point) point.style({
|
|
170
|
+
fillOpacity: 1,
|
|
171
|
+
stroke: 0
|
|
172
|
+
});
|
|
173
|
+
this.chart.render();
|
|
134
174
|
});
|
|
175
|
+
this.setToolTipForLine();
|
|
135
176
|
isFunction(customRender) && customRender(this.chart);
|
|
136
177
|
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
137
178
|
this.setValueLabel(theme);
|
|
138
|
-
this.chart.interaction('active-region');
|
|
139
179
|
if (this.isGroupChart) {
|
|
140
|
-
this.setLegend(this.groupName, theme, '
|
|
180
|
+
this.setLegend(this.groupName, theme, 'top-right');
|
|
141
181
|
}
|
|
142
182
|
};
|
|
143
183
|
this.chart = null;
|
|
144
184
|
this.groupName = 'group_name';
|
|
145
185
|
this.isGroupChart = false;
|
|
186
|
+
this.needRenderAxisLabel = true;
|
|
146
187
|
}
|
|
147
188
|
componentDidMount() {
|
|
148
189
|
this.initChartType();
|
|
149
190
|
this.createChart();
|
|
150
191
|
this.drawChart();
|
|
151
192
|
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
193
|
+
super.componentDidMount();
|
|
152
194
|
}
|
|
153
195
|
componentDidUpdate(prevProps) {
|
|
154
196
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -161,6 +203,7 @@ class Area extends ChartComponent {
|
|
|
161
203
|
}
|
|
162
204
|
componentWillUnmount() {
|
|
163
205
|
this.chart && this.chart.destroy();
|
|
206
|
+
super.componentWillUnmount();
|
|
164
207
|
}
|
|
165
208
|
render() {
|
|
166
209
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -28,7 +28,11 @@ class BasicNumericCard extends Component {
|
|
|
28
28
|
} = chart;
|
|
29
29
|
const {
|
|
30
30
|
summary_method,
|
|
31
|
-
name
|
|
31
|
+
name,
|
|
32
|
+
font_size,
|
|
33
|
+
font_color,
|
|
34
|
+
label_font_size,
|
|
35
|
+
label_font_color
|
|
32
36
|
} = config;
|
|
33
37
|
let content = null;
|
|
34
38
|
if (summary_method === 'Distinct_values') {
|
|
@@ -36,17 +40,9 @@ class BasicNumericCard extends Component {
|
|
|
36
40
|
} else {
|
|
37
41
|
content = this.formatData(result);
|
|
38
42
|
}
|
|
39
|
-
const fontSize = this.getFontSize(content);
|
|
40
|
-
let labelFontSize = fontSize - 35;
|
|
41
|
-
if (labelFontSize > 20) {
|
|
42
|
-
labelFontSize = 20;
|
|
43
|
-
}
|
|
44
|
-
if (labelFontSize < 12) {
|
|
45
|
-
labelFontSize = 12;
|
|
46
|
-
}
|
|
47
43
|
this.chart.annotation().html({
|
|
48
44
|
position: ['50%', '50%'],
|
|
49
|
-
html: "\n <div style=\"color: ".concat(theme.cardColor, "; text-align: center;\">\n <p class=\"text-content\" style=\"font-size: ").concat(
|
|
45
|
+
html: "\n <div style=\"color: ".concat(theme.cardColor, "; text-align: center;\">\n <p class=\"text-content\" style=\"font-size: ").concat(font_size, "px; color: ").concat(font_color, "; margin: -15px 0 2px 0;\">").concat(content, "</p>\n <p style=\"font-size: ").concat(label_font_size, "px; color: ").concat(label_font_color, "; margin: 0;overflow: hidden;text-overflow: ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;\">").concat(name, "</p>\n </div>\n ")
|
|
50
46
|
});
|
|
51
47
|
isFunction(customRender) && customRender(this.chart);
|
|
52
48
|
this.chart.render();
|
|
@@ -89,29 +85,6 @@ class BasicNumericCard extends Component {
|
|
|
89
85
|
}
|
|
90
86
|
return content;
|
|
91
87
|
};
|
|
92
|
-
this.getFontSize = content => {
|
|
93
|
-
let canvas = document.createElement('canvas');
|
|
94
|
-
const context = canvas.getContext('2d');
|
|
95
|
-
const {
|
|
96
|
-
width
|
|
97
|
-
} = this.chart;
|
|
98
|
-
let font = context.font;
|
|
99
|
-
let initFontSize = 50;
|
|
100
|
-
const fontStyle = font.slice(font.indexOf('px'));
|
|
101
|
-
font = initFontSize + fontStyle;
|
|
102
|
-
context.font = font;
|
|
103
|
-
context.fontSize = initFontSize;
|
|
104
|
-
while (context.measureText(content).width >= width - 40) {
|
|
105
|
-
initFontSize -= 1;
|
|
106
|
-
context.font = initFontSize + fontStyle;
|
|
107
|
-
context.fontSize = initFontSize;
|
|
108
|
-
}
|
|
109
|
-
canvas = null;
|
|
110
|
-
if (initFontSize < 16) {
|
|
111
|
-
initFontSize = 16;
|
|
112
|
-
}
|
|
113
|
-
return initFontSize;
|
|
114
|
-
};
|
|
115
88
|
}
|
|
116
89
|
componentDidUpdate(prevProps) {
|
|
117
90
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
3
|
-
import { cloneDeep } from 'lodash-es';
|
|
3
|
+
import { cloneDeep, debounce } from 'lodash-es';
|
|
4
4
|
import { Chart } from '../../utils/custom-g2';
|
|
5
5
|
import { BaseUtils } from '../../utils';
|
|
6
6
|
import { CHART_TYPE, CHART_SUMMARY_TYPE, LABEL_POSITION_TYPE, CHART_THEME_COLOR, EMPTY_NAME, THEME_NAME_MAP } from '../../constants';
|
|
@@ -10,6 +10,15 @@ export default class ChartComponent extends Component {
|
|
|
10
10
|
var _this;
|
|
11
11
|
super(...arguments);
|
|
12
12
|
_this = this;
|
|
13
|
+
this.handleResize = debounce(() => {
|
|
14
|
+
if (!this.createChart || !this.drawChart) return;
|
|
15
|
+
this.chart && this.chart.destroy();
|
|
16
|
+
this.createChart();
|
|
17
|
+
this.drawChart();
|
|
18
|
+
if (this.needRenderAxisLabel) {
|
|
19
|
+
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
20
|
+
}
|
|
21
|
+
}, 300);
|
|
13
22
|
this.initChart = (container, _ref) => {
|
|
14
23
|
let {
|
|
15
24
|
appendPadding,
|
|
@@ -389,12 +398,17 @@ export default class ChartComponent extends Component {
|
|
|
389
398
|
// Draw the bottom line back to the right edge of the left semi-circle
|
|
390
399
|
['A', r, r, 0, 0, 1, x - rectWidth / 2 - 3, y - r - 1] // Draw the left semi-circle
|
|
391
400
|
];
|
|
401
|
+
},
|
|
402
|
+
style: style => {
|
|
403
|
+
// fill legend with stroke color
|
|
404
|
+
style.fill = style.stroke;
|
|
405
|
+
return style;
|
|
392
406
|
}
|
|
393
407
|
}
|
|
394
408
|
});
|
|
395
409
|
};
|
|
396
|
-
this.
|
|
397
|
-
|
|
410
|
+
this.getToolSettings = () => {
|
|
411
|
+
return {
|
|
398
412
|
showMarkers: false,
|
|
399
413
|
domStyles: {
|
|
400
414
|
'g2-tooltip': {
|
|
@@ -431,6 +445,32 @@ export default class ChartComponent extends Component {
|
|
|
431
445
|
fontSize: '12px'
|
|
432
446
|
}
|
|
433
447
|
}
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
this.setToolTip = () => {
|
|
451
|
+
const settings = this.getToolSettings();
|
|
452
|
+
this.chart.tooltip(settings);
|
|
453
|
+
};
|
|
454
|
+
this.setToolTipForLine = () => {
|
|
455
|
+
const settings = this.getToolSettings();
|
|
456
|
+
const lineToolTipSettings = {
|
|
457
|
+
showCrosshairs: true,
|
|
458
|
+
showTitle: true,
|
|
459
|
+
shared: true,
|
|
460
|
+
showMarkers: true,
|
|
461
|
+
marker: {
|
|
462
|
+
strokeOpacity: 0,
|
|
463
|
+
r: 6
|
|
464
|
+
},
|
|
465
|
+
crosshairs: {
|
|
466
|
+
line: {
|
|
467
|
+
fill: '#e2e2e2'
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
this.chart.tooltip({
|
|
472
|
+
...settings,
|
|
473
|
+
...lineToolTipSettings
|
|
434
474
|
});
|
|
435
475
|
};
|
|
436
476
|
this.isShowXAxisLabel = chart => {
|
|
@@ -449,4 +489,10 @@ export default class ChartComponent extends Component {
|
|
|
449
489
|
return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
|
|
450
490
|
};
|
|
451
491
|
}
|
|
492
|
+
componentDidMount() {
|
|
493
|
+
window.addEventListener('resize', this.handleResize);
|
|
494
|
+
}
|
|
495
|
+
componentWillUnmount() {
|
|
496
|
+
window.removeEventListener('resize', this.handleResize);
|
|
497
|
+
}
|
|
452
498
|
}
|
|
@@ -8,11 +8,6 @@ import HorizontalComponent from './horizontal-component';
|
|
|
8
8
|
class HorizontalBar extends HorizontalComponent {
|
|
9
9
|
constructor(props) {
|
|
10
10
|
super(props);
|
|
11
|
-
this.handleResize = debounce(() => {
|
|
12
|
-
this.chart && this.chart.destroy();
|
|
13
|
-
this.createChart();
|
|
14
|
-
this.drawChart();
|
|
15
|
-
}, 300);
|
|
16
11
|
this.createChart = () => {
|
|
17
12
|
const {
|
|
18
13
|
chart
|
|
@@ -116,7 +111,7 @@ class HorizontalBar extends HorizontalComponent {
|
|
|
116
111
|
componentDidMount() {
|
|
117
112
|
this.createChart();
|
|
118
113
|
this.drawChart();
|
|
119
|
-
|
|
114
|
+
super.componentDidMount();
|
|
120
115
|
}
|
|
121
116
|
componentDidUpdate(prevProps) {
|
|
122
117
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -127,7 +122,7 @@ class HorizontalBar extends HorizontalComponent {
|
|
|
127
122
|
}
|
|
128
123
|
componentWillUnmount() {
|
|
129
124
|
this.chart && this.chart.destroy();
|
|
130
|
-
|
|
125
|
+
super.componentWillUnmount();
|
|
131
126
|
}
|
|
132
127
|
render() {
|
|
133
128
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { BaseUtils, isFunction } from '../../utils';
|
|
5
5
|
import intl from '../../intl';
|
|
6
|
+
import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
|
|
6
7
|
import ChartComponent from './chart-component';
|
|
7
8
|
class LineGroup extends ChartComponent {
|
|
8
9
|
constructor(props) {
|
|
@@ -49,11 +50,15 @@ class LineGroup extends ChartComponent {
|
|
|
49
50
|
} = this.props;
|
|
50
51
|
const {
|
|
51
52
|
y_axis_show_value,
|
|
52
|
-
label_font_size
|
|
53
|
+
label_font_size,
|
|
54
|
+
line_type,
|
|
55
|
+
y_axis_summary_type,
|
|
56
|
+
y_axis_summary_method
|
|
53
57
|
} = chart.config;
|
|
54
58
|
const chartBarColor = this.groupName;
|
|
55
59
|
const newData = this.getChartGroupData(data);
|
|
56
60
|
this.drawLabels(newData);
|
|
61
|
+
const isSmooth = line_type === CHART_LINE_TYPES[1];
|
|
57
62
|
|
|
58
63
|
// set Coord type
|
|
59
64
|
this.chart.coordinate('rect');
|
|
@@ -63,68 +68,78 @@ class LineGroup extends ChartComponent {
|
|
|
63
68
|
type: 'cat'
|
|
64
69
|
}
|
|
65
70
|
});
|
|
66
|
-
this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
71
|
+
const line = this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
67
72
|
style: {
|
|
68
73
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
69
74
|
fill: theme.textColor
|
|
70
75
|
}
|
|
71
|
-
}).
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
}).animate({
|
|
77
|
+
appear: {
|
|
78
|
+
animation: 'fadeIn',
|
|
79
|
+
duration: 1000,
|
|
80
|
+
easing: 'easeLinear'
|
|
81
|
+
}
|
|
82
|
+
}).position('name*value').color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').style({
|
|
83
|
+
lineWidth: 3,
|
|
84
|
+
opacity: 1
|
|
85
|
+
}).tooltip('group_name*name*value', (group_name, name, value) => {
|
|
86
|
+
return {
|
|
87
|
+
title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
88
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
89
|
+
name: group_name
|
|
90
|
+
};
|
|
75
91
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
borderRadius: '3px',
|
|
84
|
-
backgroundColor: '#fff',
|
|
85
|
-
padding: '16px',
|
|
86
|
-
width: '180px',
|
|
87
|
-
border: '1px solid #E2E2E2'
|
|
88
|
-
},
|
|
89
|
-
'g2-tooltip-title': {
|
|
90
|
-
color: '#333333',
|
|
91
|
-
fontSize: '14px',
|
|
92
|
-
marginTop: '-1px'
|
|
93
|
-
},
|
|
94
|
-
'tooltip-item': {
|
|
95
|
-
display: 'flex',
|
|
96
|
-
width: '100%',
|
|
97
|
-
justifyContent: 'space-between',
|
|
98
|
-
marginTop: '8px',
|
|
99
|
-
color: '#333333',
|
|
100
|
-
fontSize: '12px'
|
|
101
|
-
},
|
|
102
|
-
'tooltip-item-left': {
|
|
103
|
-
display: 'flex',
|
|
104
|
-
justifyContent: 'space-between',
|
|
105
|
-
alignItem: 'center'
|
|
106
|
-
},
|
|
107
|
-
'tooltip-item-rect': {
|
|
108
|
-
display: 'inline-block',
|
|
109
|
-
width: '12px',
|
|
110
|
-
height: '12px',
|
|
111
|
-
borderRadius: '2px',
|
|
112
|
-
marginRight: '8px'
|
|
92
|
+
let point;
|
|
93
|
+
if (y_axis_show_value) {
|
|
94
|
+
point = this.chart.point().position('name*value').color(chartBarColor).animate({
|
|
95
|
+
appear: {
|
|
96
|
+
animation: 'fadeIn',
|
|
97
|
+
duration: 1000,
|
|
98
|
+
easing: 'easeLinear'
|
|
113
99
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
100
|
+
}).shape('circle').size(4).style({
|
|
101
|
+
stroke: 0,
|
|
102
|
+
fillOpacity: 1
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
this.chart.on('tooltip:show', () => {
|
|
106
|
+
if (line.styleOption.cfg.opacity === 0.3) return;
|
|
107
|
+
line.style({
|
|
108
|
+
opacity: 0.3,
|
|
109
|
+
lineWidth: 3
|
|
110
|
+
});
|
|
111
|
+
if (point) point.style({
|
|
112
|
+
fillOpacity: 0.3,
|
|
113
|
+
stroke: 0
|
|
114
|
+
});
|
|
115
|
+
this.chart.render();
|
|
116
|
+
});
|
|
117
|
+
this.chart.on('tooltip:hide', () => {
|
|
118
|
+
if (line.styleOption.cfg.opacity === 1) return;
|
|
119
|
+
line.style({
|
|
120
|
+
opacity: 1,
|
|
121
|
+
lineWidth: 3
|
|
122
|
+
});
|
|
123
|
+
if (point) point.style({
|
|
124
|
+
fillOpacity: 1,
|
|
125
|
+
stroke: 0
|
|
126
|
+
});
|
|
127
|
+
this.chart.render();
|
|
116
128
|
});
|
|
129
|
+
this.setToolTipForLine();
|
|
117
130
|
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
118
131
|
this.setValueLabel(theme);
|
|
119
|
-
this.setLegend(this.groupName, theme, '
|
|
132
|
+
this.setLegend(this.groupName, theme, 'top-right');
|
|
120
133
|
};
|
|
121
134
|
this.chart = null;
|
|
122
135
|
this.groupName = 'group_name';
|
|
136
|
+
this.needRenderAxisLabel = true;
|
|
123
137
|
}
|
|
124
138
|
componentDidMount() {
|
|
125
139
|
this.createChart();
|
|
126
140
|
this.drawChart();
|
|
127
141
|
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
142
|
+
super.componentDidMount();
|
|
128
143
|
}
|
|
129
144
|
componentDidUpdate(prevProps) {
|
|
130
145
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -136,6 +151,7 @@ class LineGroup extends ChartComponent {
|
|
|
136
151
|
}
|
|
137
152
|
componentWillUnmount() {
|
|
138
153
|
this.chart && this.chart.destroy();
|
|
154
|
+
super.componentWillUnmount();
|
|
139
155
|
}
|
|
140
156
|
render() {
|
|
141
157
|
const {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
+
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
4
5
|
import { BaseUtils, isFunction } from '../../utils';
|
|
5
|
-
import ChartComponent from './chart-component';
|
|
6
6
|
import intl from '../../intl';
|
|
7
|
+
import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
|
|
8
|
+
import ChartComponent from './chart-component';
|
|
7
9
|
class Line extends ChartComponent {
|
|
8
10
|
constructor(props) {
|
|
9
11
|
super(props);
|
|
@@ -45,95 +47,97 @@ class Line extends ChartComponent {
|
|
|
45
47
|
const {
|
|
46
48
|
chart,
|
|
47
49
|
theme,
|
|
48
|
-
themeName
|
|
50
|
+
themeName,
|
|
51
|
+
summaryColumn
|
|
49
52
|
} = this.props;
|
|
50
53
|
const {
|
|
51
54
|
y_axis_label_color,
|
|
52
55
|
y_axis_show_value,
|
|
53
|
-
label_font_size
|
|
56
|
+
label_font_size,
|
|
57
|
+
line_type,
|
|
58
|
+
y_axis_column_key,
|
|
59
|
+
y_axis_summary_type,
|
|
60
|
+
y_axis_summary_method
|
|
54
61
|
} = chart.config;
|
|
55
62
|
let chartBarColor = y_axis_label_color || '#5B8FF9';
|
|
56
63
|
if (themeName) {
|
|
57
64
|
chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
|
|
58
65
|
}
|
|
59
66
|
this.drawLabels(data);
|
|
67
|
+
const isSmooth = line_type === CHART_LINE_TYPES[1];
|
|
60
68
|
|
|
61
69
|
// set Coord type
|
|
62
70
|
this.chart.coordinate('rect');
|
|
63
|
-
this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
71
|
+
const line = this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
64
72
|
style: {
|
|
65
73
|
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
66
|
-
fill: theme.
|
|
74
|
+
fill: theme.labelColor
|
|
67
75
|
}
|
|
68
|
-
}).
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
}).animate({
|
|
77
|
+
appear: {
|
|
78
|
+
animation: 'fadeIn',
|
|
79
|
+
duration: 1000,
|
|
80
|
+
easing: 'easeLinear'
|
|
81
|
+
}
|
|
82
|
+
}).position('name*value').color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').style({
|
|
83
|
+
lineWidth: 3,
|
|
84
|
+
opacity: 1
|
|
85
|
+
}).tooltip('name*value', (name, value) => {
|
|
86
|
+
return {
|
|
87
|
+
title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
88
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
89
|
+
name
|
|
90
|
+
};
|
|
72
91
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
borderRadius: '3px',
|
|
81
|
-
backgroundColor: '#fff',
|
|
82
|
-
padding: '16px',
|
|
83
|
-
width: '180px',
|
|
84
|
-
border: '1px solid #E2E2E2'
|
|
85
|
-
},
|
|
86
|
-
'g2-tooltip-title': {
|
|
87
|
-
color: '#333333',
|
|
88
|
-
fontSize: '14px',
|
|
89
|
-
marginTop: '-1px'
|
|
90
|
-
},
|
|
91
|
-
'tooltip-item': {
|
|
92
|
-
display: 'flex',
|
|
93
|
-
width: '100%',
|
|
94
|
-
justifyContent: 'space-between',
|
|
95
|
-
marginTop: '8px',
|
|
96
|
-
color: '#333333',
|
|
97
|
-
fontSize: '12px'
|
|
98
|
-
},
|
|
99
|
-
'tooltip-item-left': {
|
|
100
|
-
display: 'flex',
|
|
101
|
-
justifyContent: 'space-between',
|
|
102
|
-
alignItem: 'center'
|
|
103
|
-
},
|
|
104
|
-
'tooltip-item-rect': {
|
|
105
|
-
display: 'inline-block',
|
|
106
|
-
width: '12px',
|
|
107
|
-
height: '12px',
|
|
108
|
-
borderRadius: '2px',
|
|
109
|
-
marginRight: '8px'
|
|
92
|
+
let point;
|
|
93
|
+
if (y_axis_show_value) {
|
|
94
|
+
point = this.chart.point().position('name*value').color(chartBarColor).animate({
|
|
95
|
+
appear: {
|
|
96
|
+
animation: 'fadeIn',
|
|
97
|
+
duration: 1000,
|
|
98
|
+
easing: 'easeLinear'
|
|
110
99
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
100
|
+
}).shape('circle').size(4).style({
|
|
101
|
+
stroke: 0,
|
|
102
|
+
fillOpacity: 1
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
this.chart.on('tooltip:show', () => {
|
|
106
|
+
if (line.styleOption.cfg.opacity === 0.3) return;
|
|
107
|
+
line.style({
|
|
108
|
+
opacity: 0.3,
|
|
109
|
+
lineWidth: 3
|
|
110
|
+
});
|
|
111
|
+
if (point) point.style({
|
|
112
|
+
fillOpacity: 0.3,
|
|
113
|
+
stroke: 0
|
|
114
|
+
});
|
|
115
|
+
this.chart.render();
|
|
113
116
|
});
|
|
117
|
+
this.chart.on('tooltip:hide', () => {
|
|
118
|
+
if (line.styleOption.cfg.opacity === 1) return;
|
|
119
|
+
line.style({
|
|
120
|
+
opacity: 1,
|
|
121
|
+
lineWidth: 3
|
|
122
|
+
});
|
|
123
|
+
if (point) point.style({
|
|
124
|
+
fillOpacity: 1,
|
|
125
|
+
stroke: 0
|
|
126
|
+
});
|
|
127
|
+
this.chart.render();
|
|
128
|
+
});
|
|
129
|
+
this.setToolTipForLine();
|
|
114
130
|
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
115
131
|
this.setValueLabel(theme);
|
|
116
|
-
this.chart.theme({
|
|
117
|
-
geometries: {
|
|
118
|
-
point: {
|
|
119
|
-
circle: {
|
|
120
|
-
active: {
|
|
121
|
-
style: {
|
|
122
|
-
stroke: 'rgba(0, 0, 0, 0)',
|
|
123
|
-
r: 4
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
132
|
};
|
|
131
133
|
this.chart = null;
|
|
134
|
+
this.needRenderAxisLabel = true;
|
|
132
135
|
}
|
|
133
136
|
componentDidMount() {
|
|
134
137
|
this.createChart();
|
|
135
138
|
this.drawChart();
|
|
136
139
|
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
140
|
+
super.componentDidMount();
|
|
137
141
|
}
|
|
138
142
|
componentDidUpdate(prevProps) {
|
|
139
143
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -145,6 +149,7 @@ class Line extends ChartComponent {
|
|
|
145
149
|
}
|
|
146
150
|
componentWillUnmount() {
|
|
147
151
|
this.chart && this.chart.destroy();
|
|
152
|
+
super.componentWillUnmount();
|
|
148
153
|
}
|
|
149
154
|
render() {
|
|
150
155
|
const {
|