Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new kb article wrap-text-data-labels-telerik-reporting #1434

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions knowledge-base/wrap-text-data-labels-telerik-reporting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Wrapping Text in Data Labels of a Graph Report Item
description: Learn how to wrap text in the data labels of a Graph Report Item to ensure it fits within the column's width.
type: how-to
page_title: How to Wrap Text in Data Labels for Telerik Reporting
slug: wrap-text-data-labels-telerik-reporting
tags: reporting, graph, report, item, data, labels, text, wrap, column, chart
res_type: kb
ticketid: 1656974
---

## Environment

| Version | Product | Author |
| --- | --- | ---- |
| 18.1.24.514| Standalone Report Designer |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|

## Description

When using the [Graph Report Item]({%slug telerikreporting/designing-reports/report-structure/graph/overview%}) with the [Column chart]({%slug telerikreporting/designing-reports/report-structure/graph/chart-types/column-charts/overview%}) type, sometimes the text in data labels is too long, and it exceeds the column's width. This KB article demonstrates how to wrap text in data labels for a Graph Report Item or how to format long text in data labels to fit within a column in a graph report.

## Solution

To wrap text in data labels for a Column chart in the Graph Report Item, use the [built-in text functions]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/expressions-reference/functions/text-functions%}) to insert a new line character in the `DataPointLabels` text.

1. Select the `BarSeries`.
2. Set the `DataPointLabel` with the appropriate `Replace` function to insert a new line character where needed. For example:

````
= Replace(Fields.CategoryNamePlusPercent, ' ', '
')
````
![Set Replace Expression](images/replace-expression-data-point-labels.png)

![Wrapped Data Point Labels](images/wrapped-data-point-labels.png)

This function replaces spaces with a new line character, effectively wrapping the text.

Additionally, consider extending expressions for more complex formatting needs. For more details, refer to the [Extending Expressions](%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/overview%) section in the documentation.

An alternative approach is to **rotate** the labels and center the text to fit the data labels within the column's width.

![Set Label Angle](images/set-angle-data-point-labels.png)

![Rotated Data Point Labels](images/rotated-data-point-labels.png)

## Suggested Workarounds

- **Rotate the labels**: Apply rotation to the labels to make more space for the text. This can be done from the properties of the `Graph Report Item`.
- **Custom functions**: For more advanced scenarios, create custom functions to format the data labels' text.

## Notes

Experiment with text wrapping and rotation to find the best presentation for your specific case. Adjustments might be needed based on the actual data and chart size.

## See Also

- [Graph Report Item]({%slug telerikreporting/designing-reports/report-structure/graph/overview%})
- [Column Chart Type]({%slug telerikreporting/designing-reports/report-structure/graph/chart-types/column-charts/overview%})
- [Text Functions in Expressions]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/expressions-reference/functions/text-functions%})
- [Extending Expressions Overview](%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/overview%)