知識庫

Text Wrap Not Applied for Labels


發佈時間 : 04 Dec 2020
上次修改日期 : 20 Nov 2023

問題

Wrapping text labels displayed on a stacked bar chart by [Format] > [Alignment] > [Wrap] > [On] menu may not work as expected.

[Format] > [Alignment]  menu
 User-added image

環境

  • Tableau Desktop 2021, 2022 and 2023 versions

解決方法

Using a string function (eg:  LEFT() , MID())  to break up the long label string into short sub-strings can be accomplished by creating calculation fields and then displaying sub-strings one by one vertically on the bar chart.  Follow along with a sample packaged workbook found in the Attachments section of this article.

Information about string functions is available in Tableau Online Help.

Example:
1. Create calculation field [Substring1]
LEFT([Text Label],15)

2. Create calculation field [Substring2]
MID([Text Label],FIND([Text Label],",")+1,14)

3. Place [Substring1] and [Substring2] on [Text] mark label.
User-added image

其他資訊

This example is for a stacked bar chart, but the display challenge can exist in other types of chart with mark labels. The example above shows splitting the texts at 15 characters, but you can set other values or conditions depending on the requirements.
這篇文章是否解決了問題?