echarts
echarts copied to clipboard
[Bug] The width (graphic text).getBoundingRect(). is not correct.
Version
5.3.3
Link to Minimal Reproduction
No response
Steps to Reproduce
- Use this to get a Text graphic:
new echarts.graphic.Text({
style: api.style({
overflow: 'truncate',
backgroundColor: 'red',
text: 'some text here',
textFill: '#fff',
fontWeight,
fontSize,
textAlign: 'left'
})
}

-
Change the attribute text to another value, such as:
----------------
or1111111111111111111111
. -
Then you can find the background color is not cover all of the node.
For ----------------
:
For 1111111111111111111111
:

Current Behavior
The red background is not covered all of the Text graphic.
Expected Behavior
The red background can cover all of the Text graphic.
Environment
- OS:
- Browser:
- Framework:
Any additional comments?
No response
I found a quick way to reproduce. option:
option = {
title: {
text: 'Weather Statistics'
},
grid: {
left: 500
},
xAxis: {
},
yAxis: {
type: 'category',
inverse: true,
data: ['Sunny', 'Cloudy', 'Showers'],
axisLabel: {
formatter: function (value) {
return '{value|' + value + '-------------}';
},
margin: 20,
backgroundColor: 'red',
rich: {
value: {
lineHeight: 30,
align: 'center'
}
}
}
},
series: [
]
};
Set the option above to the Echarts web editor, such as: https://echarts.apache.org/examples/zh/editor.html?c=bar-rich-text

In addition, I found that in the english version, it just work fine !! So, I guess there maybe something wrong with the Chinese version?
Chinese version:
English version:

I can't reproduce this behavior on my side, no matter what the language is.
Could you take a screen shot please? Case I just find that there are some differences between those two examples. Such as the length of -
is different.
English:
Chinese:
I just can't reproduce on another computer. It's weird... @plainheart