sea-chart 0.0.47 → 0.0.48
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 +1 -0
- package/dist/model/trend.js +10 -1
- package/dist/settings/index.js +2 -2
- package/dist/settings/style-settings.js +12 -2
- package/dist/settings/trend-settings/general-font-setting.js +72 -0
- package/dist/settings/trend-settings/index.js +2 -1
- package/dist/settings/trend-settings/style-setting.js +72 -0
- package/dist/settings/widgets/title-settings/index.js +9 -3
- package/dist/view/index.css +17 -0
- package/dist/view/wrapper/chart-component.js +1 -1
- package/dist/view/wrapper/combination.js +4 -4
- package/dist/view/wrapper/line-group.js +1 -1
- package/dist/view/wrapper/line.js +1 -1
- package/dist/view/wrapper/trend.js +22 -39
- package/package.json +1 -1
package/dist/constants/index.js
CHANGED
|
@@ -198,6 +198,7 @@ export const LEGEND_DIRECTION = {
|
|
|
198
198
|
export const MIRROR_COLUMN_LIST = [CellType.TEXT, CellType.NUMBER, CellType.CTIME, CellType.MTIME, CellType.DATE, CellType.COLLABORATOR, CellType.AUTO_NUMBER, CellType.FORMULA, CellType.GEOLOCATION, CellType.URL, CellType.SINGLE_SELECT, CellType.LINK, CellType.CREATOR, CellType.LAST_MODIFIER, CellType.DURATION, CellType.EMAIL];
|
|
199
199
|
export const CHART_SUPPORT_FONT_WEIGHTS = [400, 700];
|
|
200
200
|
export const DEFAULT_CHART_FONT_WEIGHT = CHART_SUPPORT_FONT_WEIGHTS[1];
|
|
201
|
+
export const DAFAULT_TREND_CHART_TITLE_FONT_SIZE = 16;
|
|
201
202
|
export const DEFAULT_CHART_TITLE_FONT_SIZE = 18;
|
|
202
203
|
export const DEFAULT_CHART_TITLE_FONT_COLOR = '#212529';
|
|
203
204
|
export const CHART_SETTINGS_TYPE = {
|
package/dist/model/trend.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTableColumnByKey, isDateColumn } from 'dtable-utils';
|
|
2
|
-
import { CHART_TYPE } from '../constants';
|
|
2
|
+
import { CHART_TYPE, HORIZONTAL_ALIGN } from '../constants';
|
|
3
3
|
import BaseModel from './base-model';
|
|
4
4
|
class Trend extends BaseModel {
|
|
5
5
|
constructor(options, table) {
|
|
@@ -19,6 +19,15 @@ class Trend extends BaseModel {
|
|
|
19
19
|
this.summary_type = options.y_axis_summary_type || 'count';
|
|
20
20
|
this.summary_column_key = options.y_axis_summary_column_key;
|
|
21
21
|
this.summary_method = options.y_axis_summary_method;
|
|
22
|
+
this.num_font_size = options.num_font_size || 34;
|
|
23
|
+
this.num_font_color = options.num_font_color || '#212529';
|
|
24
|
+
this.num_text_align = options.num_text_align || HORIZONTAL_ALIGN.LEFT;
|
|
25
|
+
this.num_font_weight = options.num_font_weight || 700;
|
|
26
|
+
this.label = options.label || '';
|
|
27
|
+
this.card_label_font_size = options.card_label_font_size || 14;
|
|
28
|
+
this.label_font_color = options.label_font_color || '#999999';
|
|
29
|
+
this.label_text_align = options.label_text_align || HORIZONTAL_ALIGN.LEFT;
|
|
30
|
+
this.label_font_weight = options.label_font_weight || 400;
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
export default Trend;
|
package/dist/settings/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react';
|
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { eventStopPropagation } from '../utils';
|
|
4
4
|
import { BaseUtils } from '../utils';
|
|
5
|
-
import DataSettings from './data-settings';
|
|
6
|
-
import StyleSettings from './style-settings';
|
|
7
5
|
import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
|
|
8
6
|
import intl from '../intl';
|
|
7
|
+
import DataSettings from './data-settings';
|
|
8
|
+
import StyleSettings from './style-settings';
|
|
9
9
|
import Divider from './widgets/divider';
|
|
10
10
|
import './index.css';
|
|
11
11
|
const Settings = _ref => {
|
|
@@ -12,6 +12,7 @@ import { HeatMapStyleSettings } from './heat-map-settings';
|
|
|
12
12
|
import StatisticTitleSetting from './widgets/title-settings';
|
|
13
13
|
import { CompletenessStyleSettings } from './completeness-settings';
|
|
14
14
|
import { MapStyleSettings } from './map-settings';
|
|
15
|
+
import { TrendStyleSettings } from './trend-settings';
|
|
15
16
|
const StyleSettings = _ref => {
|
|
16
17
|
let {
|
|
17
18
|
chart,
|
|
@@ -44,12 +45,17 @@ const StyleSettings = _ref => {
|
|
|
44
45
|
}, [chart, onChange]);
|
|
45
46
|
const renderTitleSettings = useCallback(() => {
|
|
46
47
|
const {
|
|
47
|
-
style_config
|
|
48
|
+
style_config,
|
|
49
|
+
config
|
|
48
50
|
} = chart;
|
|
51
|
+
const {
|
|
52
|
+
type
|
|
53
|
+
} = config;
|
|
49
54
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StatisticTitleSetting, {
|
|
50
55
|
key: "title-setting-".concat(chart.id),
|
|
51
56
|
title: style_config && style_config.title,
|
|
52
|
-
modifyTitle: modifyTitle
|
|
57
|
+
modifyTitle: modifyTitle,
|
|
58
|
+
type: type
|
|
53
59
|
}), /*#__PURE__*/React.createElement(Divider, null));
|
|
54
60
|
}, [chart, modifyTitle]);
|
|
55
61
|
const renderStatisticStyleSettings = useCallback(() => {
|
|
@@ -121,6 +127,10 @@ const StyleSettings = _ref => {
|
|
|
121
127
|
{
|
|
122
128
|
return /*#__PURE__*/React.createElement(HeatMapStyleSettings, props);
|
|
123
129
|
}
|
|
130
|
+
case CHART_TYPE.TREND:
|
|
131
|
+
{
|
|
132
|
+
return /*#__PURE__*/React.createElement(TrendStyleSettings, props);
|
|
133
|
+
}
|
|
124
134
|
default:
|
|
125
135
|
{
|
|
126
136
|
return null;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { FormGroup, Input, Label } from 'reactstrap';
|
|
3
|
+
import intl from '../../intl';
|
|
4
|
+
import { FontColorSettings, FontSizeSettings, FontWeightSettings } from '../widgets/font-settings';
|
|
5
|
+
import TextHorizontalSettings from '../widgets/text-horizontal-settings';
|
|
6
|
+
import { CHART_SUPPORT_FONT_WEIGHTS } from '../../constants';
|
|
7
|
+
export default function GeneralFontSetting(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
labelTitle,
|
|
10
|
+
config,
|
|
11
|
+
defaultConfig,
|
|
12
|
+
onChange
|
|
13
|
+
} = _ref;
|
|
14
|
+
const {
|
|
15
|
+
font_size,
|
|
16
|
+
font_color,
|
|
17
|
+
text_align,
|
|
18
|
+
label,
|
|
19
|
+
font_weight
|
|
20
|
+
} = config;
|
|
21
|
+
const {
|
|
22
|
+
font_size: defaultFontSize,
|
|
23
|
+
font_color: defaultFontColor,
|
|
24
|
+
text_align: defaultTextAlign,
|
|
25
|
+
font_weight: defaultFontWeight
|
|
26
|
+
} = defaultConfig;
|
|
27
|
+
const labelRef = useRef(null);
|
|
28
|
+
const [currentLabel, setCurrentLabel] = useState(label);
|
|
29
|
+
const handleLabelChange = e => {
|
|
30
|
+
setCurrentLabel(e.target.value);
|
|
31
|
+
};
|
|
32
|
+
const onSaveLabel = () => {
|
|
33
|
+
onChange('label', currentLabel);
|
|
34
|
+
};
|
|
35
|
+
const handleFontSizeChange = updatedFontSize => {
|
|
36
|
+
onChange('font_size', updatedFontSize);
|
|
37
|
+
};
|
|
38
|
+
const handleFontColorChange = updatedFontColor => {
|
|
39
|
+
onChange('font_color', updatedFontColor);
|
|
40
|
+
};
|
|
41
|
+
const handleTextAlignChange = value => {
|
|
42
|
+
onChange('text_align', value);
|
|
43
|
+
};
|
|
44
|
+
const handleFontWeightChange = value => {
|
|
45
|
+
onChange('font_weight', value);
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, labelTitle && /*#__PURE__*/React.createElement(FormGroup, {
|
|
48
|
+
className: "sea-chart-parameter-item"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Label, null, intl.get(labelTitle)), /*#__PURE__*/React.createElement(Input, {
|
|
50
|
+
ref: labelRef,
|
|
51
|
+
type: "text",
|
|
52
|
+
value: currentLabel,
|
|
53
|
+
onBlur: onSaveLabel,
|
|
54
|
+
onChange: handleLabelChange
|
|
55
|
+
})), /*#__PURE__*/React.createElement(FontSizeSettings, {
|
|
56
|
+
fontSize: font_size,
|
|
57
|
+
defaultFontSize: defaultFontSize,
|
|
58
|
+
modifyFontSize: handleFontSizeChange
|
|
59
|
+
}), /*#__PURE__*/React.createElement(FontWeightSettings, {
|
|
60
|
+
fontWeight: font_weight || defaultFontWeight,
|
|
61
|
+
supportFontWeights: CHART_SUPPORT_FONT_WEIGHTS,
|
|
62
|
+
modifyFontWeight: handleFontWeightChange
|
|
63
|
+
}), /*#__PURE__*/React.createElement(FontColorSettings, {
|
|
64
|
+
fontColor: font_color,
|
|
65
|
+
defaultFontColor: defaultFontColor,
|
|
66
|
+
modifyFontColor: handleFontColorChange
|
|
67
|
+
}), /*#__PURE__*/React.createElement(TextHorizontalSettings, {
|
|
68
|
+
value: text_align,
|
|
69
|
+
defaultValue: defaultTextAlign,
|
|
70
|
+
onChange: handleTextAlignChange
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Label } from 'reactstrap';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import intl from '../../intl';
|
|
4
|
+
import Divider from '../widgets/divider';
|
|
5
|
+
import GeneralFontSetting from './general-font-setting';
|
|
6
|
+
export default function StyleSettings(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
chart,
|
|
9
|
+
onChange
|
|
10
|
+
} = _ref;
|
|
11
|
+
const {
|
|
12
|
+
config
|
|
13
|
+
} = chart;
|
|
14
|
+
const {
|
|
15
|
+
num_font_size,
|
|
16
|
+
num_font_color,
|
|
17
|
+
num_text_align,
|
|
18
|
+
num_font_weight,
|
|
19
|
+
card_label_font_size: label_font_size,
|
|
20
|
+
label_font_color,
|
|
21
|
+
label_text_align,
|
|
22
|
+
label_font_weight
|
|
23
|
+
} = config;
|
|
24
|
+
const numConfig = {
|
|
25
|
+
font_size: num_font_size,
|
|
26
|
+
font_color: num_font_color,
|
|
27
|
+
text_align: num_text_align,
|
|
28
|
+
font_weight: num_font_weight
|
|
29
|
+
};
|
|
30
|
+
const defaultNumConfig = {
|
|
31
|
+
font_size: 34,
|
|
32
|
+
font_color: '#212529',
|
|
33
|
+
text_align: 'left',
|
|
34
|
+
font_weight: 700
|
|
35
|
+
};
|
|
36
|
+
const labelConfig = {
|
|
37
|
+
font_size: label_font_size,
|
|
38
|
+
font_color: label_font_color,
|
|
39
|
+
text_align: label_text_align,
|
|
40
|
+
font_weight: label_font_weight
|
|
41
|
+
};
|
|
42
|
+
const defaultLabelConfig = {
|
|
43
|
+
font_size: 14,
|
|
44
|
+
font_color: '#999999',
|
|
45
|
+
text_align: 'left',
|
|
46
|
+
font_weight: 400
|
|
47
|
+
};
|
|
48
|
+
const handleNumChange = (key, value) => {
|
|
49
|
+
key = "num_".concat(key);
|
|
50
|
+
onChange({
|
|
51
|
+
[key]: value
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const handleLabelChange = (key, value) => {
|
|
55
|
+
key = "label_".concat(key);
|
|
56
|
+
if (key === 'label_font_size') {
|
|
57
|
+
key = 'card_label_font_size';
|
|
58
|
+
}
|
|
59
|
+
onChange({
|
|
60
|
+
[key]: value
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Label, null, intl.get('Number_settings')), /*#__PURE__*/React.createElement(GeneralFontSetting, {
|
|
64
|
+
config: numConfig,
|
|
65
|
+
defaultConfig: defaultNumConfig,
|
|
66
|
+
onChange: handleNumChange
|
|
67
|
+
}), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Label, null, intl.get('Label_settings')), /*#__PURE__*/React.createElement(GeneralFontSetting, {
|
|
68
|
+
config: labelConfig,
|
|
69
|
+
defaultConfig: defaultLabelConfig,
|
|
70
|
+
onChange: handleLabelChange
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import TitleText from './title-text';
|
|
3
2
|
import { FontSizeSettings, FontWeightSettings, FontColorSettings } from '../font-settings';
|
|
4
3
|
import TextHorizontalSettings from '../text-horizontal-settings';
|
|
5
|
-
import { DEFAULT_CHART_FONT_WEIGHT, DEFAULT_CHART_TITLE_FONT_SIZE, CHART_SUPPORT_FONT_WEIGHTS, HORIZONTAL_ALIGN, DEFAULT_CHART_TITLE_FONT_COLOR } from '../../../constants';
|
|
4
|
+
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';
|
|
5
|
+
import TitleText from './title-text';
|
|
6
6
|
const TitleSetting = props => {
|
|
7
7
|
const initialTitle = useMemo(() => {
|
|
8
8
|
return props.title || {};
|
|
@@ -45,12 +45,18 @@ const TitleSetting = props => {
|
|
|
45
45
|
font_color: updatedFontColor
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
|
+
const isTrend = props.type === CHART_TYPE.TREND;
|
|
49
|
+
|
|
50
|
+
// if no text then set trend default font size to 16
|
|
51
|
+
if (isTrend && !initialTitle.TitleText) {
|
|
52
|
+
initialTitle.font_size = DAFAULT_TREND_CHART_TITLE_FONT_SIZE;
|
|
53
|
+
}
|
|
48
54
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TitleText, {
|
|
49
55
|
text: initialTitle.text,
|
|
50
56
|
modifyText: modifyText
|
|
51
57
|
}), /*#__PURE__*/React.createElement(FontSizeSettings, {
|
|
52
58
|
fontSize: initialTitle.font_size,
|
|
53
|
-
defaultFontSize: DEFAULT_CHART_TITLE_FONT_SIZE,
|
|
59
|
+
defaultFontSize: isTrend ? DAFAULT_TREND_CHART_TITLE_FONT_SIZE : DEFAULT_CHART_TITLE_FONT_SIZE,
|
|
54
60
|
modifyFontSize: modifyFontSize
|
|
55
61
|
}), /*#__PURE__*/React.createElement(FontWeightSettings, {
|
|
56
62
|
fontWeight: initialTitle.font_weight || DEFAULT_CHART_FONT_WEIGHT,
|
package/dist/view/index.css
CHANGED
|
@@ -47,11 +47,28 @@
|
|
|
47
47
|
bottom: 2%;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.sea-chart-formatter .sea-chart-container.plugin-number-card-trend {
|
|
51
|
+
bottom: 0 !important;
|
|
52
|
+
left: 0 !important;
|
|
53
|
+
right: 0 !important;
|
|
54
|
+
top: 0 !important;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sea-chart-formatter .sea-chart-trend-formatter-container {
|
|
60
|
+
padding: 20px;
|
|
61
|
+
border: 2px solid #e2e2e2;
|
|
62
|
+
border-radius: 6px;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
.sea-chart-formatter .sea-chart-container.show-x-axis-label,
|
|
51
66
|
.sea-chart-formatter .sea-chart-container.show-horizontal-axis-label {
|
|
52
67
|
padding-bottom: 20px;
|
|
53
68
|
}
|
|
54
69
|
|
|
70
|
+
|
|
71
|
+
|
|
55
72
|
.sea-chart-formatter .sea-chart-container.show-y-axis-label,
|
|
56
73
|
.sea-chart-formatter .sea-chart-container.show-y-axis-left-label,
|
|
57
74
|
.sea-chart-formatter .sea-chart-container.show-vertical-axis-label {
|
|
@@ -262,7 +262,7 @@ class Combination extends ChartComponent {
|
|
|
262
262
|
duration: 1000,
|
|
263
263
|
easing: 'easeLinear'
|
|
264
264
|
}
|
|
265
|
-
}).shape('circle').size(
|
|
265
|
+
}).shape('circle').size(3).style({
|
|
266
266
|
stroke: 0,
|
|
267
267
|
fillOpacity: 1
|
|
268
268
|
}).label(display_data ? 'value_right' : false, {
|
|
@@ -371,9 +371,9 @@ class Combination extends ChartComponent {
|
|
|
371
371
|
// fillOpacity: 0.3,
|
|
372
372
|
// });
|
|
373
373
|
point.style('name', name => {
|
|
374
|
-
let r =
|
|
374
|
+
let r = 3;
|
|
375
375
|
if (name === e.data.data.name) {
|
|
376
|
-
r =
|
|
376
|
+
r = 5;
|
|
377
377
|
}
|
|
378
378
|
return {
|
|
379
379
|
r,
|
|
@@ -391,7 +391,7 @@ class Combination extends ChartComponent {
|
|
|
391
391
|
// fillOpacity: 1,
|
|
392
392
|
// });
|
|
393
393
|
point.style('name', name => {
|
|
394
|
-
let r =
|
|
394
|
+
let r = 3;
|
|
395
395
|
return {
|
|
396
396
|
r,
|
|
397
397
|
stroke: 0,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
import { Chart } from '../../utils/custom-g2';
|
|
3
4
|
import { BaseUtils } from '../../utils';
|
|
4
5
|
import intl from '../../intl';
|
|
@@ -25,16 +26,22 @@ class Trend extends Component {
|
|
|
25
26
|
config
|
|
26
27
|
} = chart;
|
|
27
28
|
const {
|
|
28
|
-
summary_method
|
|
29
|
+
summary_method,
|
|
30
|
+
num_font_size,
|
|
31
|
+
num_font_color,
|
|
32
|
+
num_font_weight,
|
|
33
|
+
num_text_align,
|
|
34
|
+
card_label_font_size: label_font_size,
|
|
35
|
+
label_font_color,
|
|
36
|
+
label_text_align,
|
|
37
|
+
label_font_weight
|
|
29
38
|
} = config;
|
|
30
39
|
const latest = result && result.latest;
|
|
31
40
|
const content = summary_method === CHART_SUMMARY_TYPE.Distinct_values ? latest : this.formatData(latest);
|
|
32
|
-
const
|
|
33
|
-
let labelFontSize = fontSize - 32;
|
|
34
|
-
const labelContent = this.createLabelContent(result, labelFontSize);
|
|
41
|
+
const labelContent = this.createLabelContent(result, label_text_align, label_font_size, label_font_color, label_font_weight);
|
|
35
42
|
this.chart.annotation().html({
|
|
36
|
-
|
|
37
|
-
html: "\n <div style=\"color:".concat(theme.cardColor, ";
|
|
43
|
+
container: this.container,
|
|
44
|
+
html: "\n <div style=\"color:".concat(theme.cardColor, "; width: 100%; height: 100%; position: relative\">\n <p class=\"text-content\" style=\" position:absolute; width: 100%; top: calc((100% - 22px)/2); transform: translateY(-50%); font-size: ").concat(num_font_size, "px; margin: -8px 0 2px 0; text-align: ").concat(num_text_align, "; font-weight:").concat(num_font_weight, "; color:").concat(num_font_color, "\">").concat(content, "</p>\n <p class=\"label-content\" style=\"position:absolute; width: 100%; bottom: 0px; margin: 0;\">").concat(labelContent, "</p>\n </div>\n ")
|
|
38
45
|
});
|
|
39
46
|
this.chart.render();
|
|
40
47
|
};
|
|
@@ -76,30 +83,7 @@ class Trend extends Component {
|
|
|
76
83
|
}
|
|
77
84
|
return content;
|
|
78
85
|
};
|
|
79
|
-
this.
|
|
80
|
-
let canvas = document.createElement('canvas');
|
|
81
|
-
const context = canvas.getContext('2d');
|
|
82
|
-
const {
|
|
83
|
-
width
|
|
84
|
-
} = this.chart;
|
|
85
|
-
let font = context.font;
|
|
86
|
-
let initFontSize = 50;
|
|
87
|
-
const fontStyle = font.slice(font.indexOf('px'));
|
|
88
|
-
font = initFontSize + fontStyle;
|
|
89
|
-
context.font = font;
|
|
90
|
-
context.fontSize = initFontSize;
|
|
91
|
-
while (context.measureText(content).width >= width - 40) {
|
|
92
|
-
initFontSize -= 1;
|
|
93
|
-
context.font = initFontSize + fontStyle;
|
|
94
|
-
context.fontSize = initFontSize;
|
|
95
|
-
}
|
|
96
|
-
canvas = null;
|
|
97
|
-
if (initFontSize < 16) {
|
|
98
|
-
initFontSize = 16;
|
|
99
|
-
}
|
|
100
|
-
return initFontSize;
|
|
101
|
-
};
|
|
102
|
-
this.createLabelContent = (data, maxFontSize) => {
|
|
86
|
+
this.createLabelContent = (data, label_text_align, labelFontSize, labelFontColor, labelFontWeight) => {
|
|
103
87
|
const {
|
|
104
88
|
chart
|
|
105
89
|
} = this.props;
|
|
@@ -130,26 +114,24 @@ class Trend extends Component {
|
|
|
130
114
|
type,
|
|
131
115
|
previous
|
|
132
116
|
} = data || {};
|
|
133
|
-
let color = '#
|
|
134
|
-
icon = '
|
|
117
|
+
let color = '#fa5757',
|
|
118
|
+
icon = '↓';
|
|
135
119
|
if (type === 'up') {
|
|
136
|
-
color = '#
|
|
137
|
-
icon = '
|
|
120
|
+
color = '#34aa95';
|
|
121
|
+
icon = '↑';
|
|
138
122
|
}
|
|
139
123
|
let resultText = "".concat(Number.parseFloat(result * 100).toFixed(2), "%•").concat(conjunctions).concat(previous);
|
|
140
124
|
if (!previous) {
|
|
141
125
|
resultText = intl.get('Can_not_compare_with_{var}').replace('{var}', intl.get(conjunctions));
|
|
142
126
|
}
|
|
143
|
-
let labelFontSize = this.getFontSize(resultText, maxFontSize);
|
|
144
|
-
labelFontSize = labelFontSize > 20 ? 20 : labelFontSize;
|
|
145
127
|
if (!previous) {
|
|
146
128
|
return "<span style='font-size: ".concat(labelFontSize, "px'>").concat(resultText, "</span>");
|
|
147
129
|
}
|
|
148
130
|
if (labelFontSize <= 12) {
|
|
149
131
|
if (!result) return '';
|
|
150
|
-
return "<span style='font-size: ".concat(labelFontSize, "px; width: 100%;'>\n <i style='color: ").concat(color, "
|
|
132
|
+
return "<span style='font-size: ".concat(labelFontSize, "px; width: 100%;'>\n <i \n style='color: ").concat(color, "; \n display: inline-block; \n width: ").concat(1.5 * labelFontSize, "px; \n height: ").concat(1.5 * labelFontSize, "px; \n line-height: ").concat(1.5 * labelFontSize, "px; \n border-radius: 50%; \n background-color: ").concat(color, "26;\n text-align: center;\n margin-right: 8px;\n font-weight: bold;\n '>\n ").concat(icon, "\n </i>\n <span style='color: ").concat(color, "'>").concat(result ? Number.parseFloat(result * 100).toFixed(2) : '', "%</span>\n </span>");
|
|
151
133
|
}
|
|
152
|
-
const resultContent = "\n <span style='display:
|
|
134
|
+
const resultContent = "\n <span style='display: flex; flex-wrap:wrap; justify-content:".concat(label_text_align, "; font-size: ").concat(labelFontSize, "px; width: 100%;'>\n <span style=\"white-space:nowrap\"> ").concat(!result ? '' : "\n <i \n style='\n flex-shrink:0;\n flex-basis:auto;\n color: ".concat(color, "; \n display: inline-block; \n width: ").concat(1.5 * labelFontSize, "px; \n height: ").concat(1.5 * labelFontSize, "px; \n line-height: ").concat(1.5 * labelFontSize, "px; \n border-radius: 50%; \n background-color: ").concat(color, "26;\n text-align: center;\n margin-right: 8px;\n font-weight: bold;\n '\n >\n ").concat(icon, "\n </i>"), "<span style='color: ").concat(color, "; margin-right: 0px '>\n ").concat(result ? Number.parseFloat(result * 100).toFixed(2) + '%' : '', "\n </span></span><span style=\"color:").concat(labelFontColor, "; font-weight:").concat(labelFontWeight, "; white-space:nowrap; margin-left: 16px \">\n ").concat(conjunctions, " \n ").concat(this.formatData(previous), "\n </span>\n </span>\n ");
|
|
153
135
|
return resultContent;
|
|
154
136
|
};
|
|
155
137
|
}
|
|
@@ -160,9 +142,10 @@ class Trend extends Component {
|
|
|
160
142
|
}
|
|
161
143
|
}
|
|
162
144
|
render() {
|
|
145
|
+
// const { chart } = this.props;
|
|
163
146
|
return /*#__PURE__*/React.createElement("div", {
|
|
164
147
|
ref: ref => this.container = ref,
|
|
165
|
-
className:
|
|
148
|
+
className: classNames('sea-chart-container', 'plugin-number-card-trend')
|
|
166
149
|
});
|
|
167
150
|
}
|
|
168
151
|
}
|