KNOWLEDGE BASE

Text Wrap Not Applied for Labels


Pubblicato: 04 Dec 2020
Data dell'ultima modifica: 20 Nov 2023

Problema

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

Ambiente

  • Tableau Desktop 2021, 2022 and 2023 versions

Soluzione

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

Ulteriori informazioni

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.
Con questo articolo hai risolto il problema?