apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.8k stars 19.62k forks source link

[Bug] Tooltip with renderMode: 'richText' does not apply rich styling to formatter. #19966

Open GidianB opened 6 months ago

GidianB commented 6 months ago

Version

5.5.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/zh/editor.html?c=bar-simple&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AMYCGYVA5sAE7m0A0J6AE2aMiAbVoBZGL1i0AKgFcqM2gHUqAlXIAWClQDEOEFQGVmphdFoBdEgF8-6cjnxFUpMpRqyAbowA2SrT2jmTAwP6QIG78sBxU0AJUHFJJdEb02nJUGGC8sQBmnAC2zCwcRAAUIIwcjMV4AJTo8AB8xB7o8WAKHHCwAAawACRINXUNAHTQ9VR2bgBGgVQAPqPj9XiTfst2dgOxDrEA9McAQlT-wADusHgU_hDQrLD4sNDAYLCMICCPGrEMtoYp1YEslCDQbB6BFOHRwcpQqCitAwOoIKxtGB4RFNEjSHZDviWLkTA9vO5OkDIaCETSoTCrhVZAj8lDSCi0VQMVicf48bEPITQcKCSESHhkhAqIRYKJYpSPEIwCI5QBGABMAAYeLBtTrYGqAKwGgAcBoA7Aa1WrrQBmLXWfHoCjUeG1YJCki2OwAbiAA

Steps to Reproduce

Specify renderMode: 'richText' in the tooltip and use richText formatting in the formatter. Then specify the richText styling in tooltip.rich or in tooltip.textStyle.rich

Current Behavior

Currently, rich is not supported by tooltip, and renderMode:'richText' seems to be a useless option. In wechat applets without DOM, there is no way to customize different styles.

Expected Behavior

rich styling should be applied to the formatter.

Environment

- OS: Windows 10
- Browser: Chrome

Any additional comments?

What does the proposed API look like?

tooltip.rich or tooltip.textStyle.rich

helgasoft commented 6 months ago

Agree, renderMode 'richText' is misleading since there is no rich in tooltip API. Technically we cannot call it a bug since rich is missing, but I think rich was meant to be used, just some source code was not hooked up...? Proof: tooltip recognizes 'rred' as rich format and does not display it as string, but does not apply it as format either.

  formatter: '{b}: {rred|{c} }',
  renderMode: 'richText',
  rich: {
    primary: { color: 'magenta' },
    rred: { color: 'red', fontWeight: 'bold' }
  },

So this issue could be updated to a valid and very useful New Feature Request. EDIT: found a duplicate #12232 and a pending PR https://github.com/apache/echarts/pull/14994. EDIT2: as of Aug 2024 the above proof code does not work anymore

EDIT final: renderMode:'richText' has nothing to do with rich formatting, but with DOM and apps like WeChat. So I virtually retract all my "findings" (nonsense) above 😓

Ovilia commented 5 months ago

@helgasoft Thanks for the information! I will review the PR tomorrow.

GidianB commented 4 months ago

@Ovilia any update on this?

gufengpiaoyi commented 3 months ago

any update on this?

zhanzz commented 1 month ago

any update on this?

Travelguest commented 3 weeks ago

any update on this?