fix: update Ring component for long text display
1. When the text is long, change the font size smaller 2. Fix lineHeight value for the Annatation.Text component Change-Id: I71b96864de15bb0b4b331c7e70ea23a80b759b82
This commit is contained in:
parent
27a2f095ea
commit
2c8990c591
@ -46,6 +46,11 @@ export const getUsedValueColor = (percent) => {
|
|||||||
return typeColors.used;
|
return typeColors.used;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const testChinese = (str) => {
|
||||||
|
const reg = /[\u4e00-\u9fa5]+/g;
|
||||||
|
return str.match(reg);
|
||||||
|
};
|
||||||
|
|
||||||
export default function Ring(props) {
|
export default function Ring(props) {
|
||||||
const {
|
const {
|
||||||
used = 0,
|
used = 0,
|
||||||
@ -109,6 +114,15 @@ export default function Ring(props) {
|
|||||||
tipTitle = tips.join(' / ');
|
tipTitle = tips.join(' / ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const titleLength = title.length;
|
||||||
|
const titleFontSize = testChinese(title)
|
||||||
|
? titleLength > 6
|
||||||
|
? 10
|
||||||
|
: 14
|
||||||
|
: titleLength > 12
|
||||||
|
? 10
|
||||||
|
: 14;
|
||||||
|
|
||||||
const chart = (
|
const chart = (
|
||||||
<Chart placeholder={false} height={height} padding="auto" autoFit>
|
<Chart placeholder={false} height={height} padding="auto" autoFit>
|
||||||
<Legend visible={showTip && hasLabel} />
|
<Legend visible={showTip && hasLabel} />
|
||||||
@ -126,8 +140,8 @@ export default function Ring(props) {
|
|||||||
position={['50%', '30%']}
|
position={['50%', '30%']}
|
||||||
content={title}
|
content={title}
|
||||||
style={{
|
style={{
|
||||||
lineHeight: '240px',
|
lineHeight: 1.5,
|
||||||
fontSize: '14',
|
fontSize: titleFontSize,
|
||||||
fill: '#000',
|
fill: '#000',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
@ -136,8 +150,8 @@ export default function Ring(props) {
|
|||||||
position={['50%', '50%']}
|
position={['50%', '50%']}
|
||||||
content={secondTitle}
|
content={secondTitle}
|
||||||
style={{
|
style={{
|
||||||
lineHeight: '240px',
|
lineHeight: 1.5,
|
||||||
fontSize: '14',
|
fontSize: 14,
|
||||||
fill: '#000',
|
fill: '#000',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
@ -146,8 +160,8 @@ export default function Ring(props) {
|
|||||||
position={['50%', '70%']}
|
position={['50%', '70%']}
|
||||||
content={`${allCount}/${limitStr}`}
|
content={`${allCount}/${limitStr}`}
|
||||||
style={{
|
style={{
|
||||||
lineHeight: '240px',
|
lineHeight: 1.5,
|
||||||
fontSize: '14',
|
fontSize: 14,
|
||||||
fill: getUsedValueColor(percent),
|
fill: getUsedValueColor(percent),
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
|
Loading…
Reference in New Issue
Block a user