echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] The width (graphic text).getBoundingRect(). is not correct.

Open jianqi-jin opened this issue 2 years ago • 6 comments

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'
    })
  }
image
  • Change the attribute text to another value, such as: ---------------- or 1111111111111111111111.

  • Then you can find the background color is not cover all of the node.

For ----------------: image

For 1111111111111111111111:

image

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

jianqi-jin avatar Sep 20 '22 10:09 jianqi-jin

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

image

jianqi-jin avatar Sep 20 '22 11:09 jianqi-jin

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

jianqi-jin avatar Sep 20 '22 11:09 jianqi-jin

Chinese version: image

English version:

image

jianqi-jin avatar Sep 20 '22 11:09 jianqi-jin

I can't reproduce this behavior on my side, no matter what the language is.

plainheart avatar Sep 20 '22 12:09 plainheart

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: image

Chinese: image

jianqi-jin avatar Sep 20 '22 12:09 jianqi-jin

I just can't reproduce on another computer. It's weird... @plainheart

jianqi-jin avatar Sep 21 '22 10:09 jianqi-jin