|
| 1 | +--- |
| 2 | +title: Aligning Legend Items Vertically in Telerik Reporting |
| 3 | +description: Learn how to arrange legend items vertically in Telerik Reporting Graph items using non-breaking spaces or custom legends. |
| 4 | +type: how-to |
| 5 | +page_title: Making Legend Items Appear One Per Line in Telerik Reporting |
| 6 | +meta_title: Making Legend Items Appear One Per Line in Telerik Reporting |
| 7 | +slug: aligning-legend-items-vertically-telerik-reporting |
| 8 | +tags: reporting, legend, histogram, custom-legend, non-breaking-space |
| 9 | +res_type: kb |
| 10 | +ticketid: 1699541 |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment |
| 14 | +<table> |
| 15 | +<tbody> |
| 16 | +<tr> |
| 17 | +<td>Product</td> |
| 18 | +<td>Reporting</td> |
| 19 | +</tr> |
| 20 | +</tbody> |
| 21 | +</table> |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +I want the legend items in my chart to appear vertically, with one item per line, instead of multiple items on the same line. Adding spaces did not work as the whitespace gets trimmed, and the items still align horizontally. |
| 26 | + |
| 27 | +This knowledge base article also answers the following questions: |
| 28 | +- How to vertically align legend items in Telerik Reporting? |
| 29 | +- How to use non-breaking spaces in legend items for vertical arrangement? |
| 30 | +- How to create a custom legend layout in Telerik Reporting? |
| 31 | + |
| 32 | +## Solution |
| 33 | + |
| 34 | +To align legend items vertically so that each item appears on a separate line, follow these solutions: |
| 35 | + |
| 36 | +### Using Non-Breaking Spaces |
| 37 | + |
| 38 | +* Use a string of Narrow Non-breaking spaces (` `) in the legend item value. You may copy and paste other non-breaking spaces from the [Wikipedia Non-breaking Space article](https://en.wikipedia.org/wiki/Non-breaking_space) or other sources. |
| 39 | +* Update the legend item value with these spaces, ensuring enough spaces are added to the end for alignment. Non-breaking spaces prevent trimming and help space out items. |
| 40 | + |
| 41 | +Here is the Graph layout with the default legend: |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +And the steps and the layout after applying the non-breaking spaces: |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +### Creating a Custom Legend |
| 50 | + |
| 51 | +1. Place a `List` or `Table` report item next to the chart. |
| 52 | +1. Bind the `List` or `Table` representing the legend to the corresponding data. |
| 53 | +1. Configure the Table/List cells to display the required marks and text. For the former, you may use [PictureBox]({%slug telerikreporting/designing-reports/report-structure/picturebox%}) or [Shape]({%slug telerikreporting/designing-reports/report-structure/shape%}). Consider also [Conditional Formatting]({%slug telerikreporting/designing-reports/styling-reports/conditional-formatting%}) and [Bindings]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/using-expressions/bindings%}) for the styles. |
| 54 | + |
| 55 | +### Using a User Function |
| 56 | + |
| 57 | +1. Create a user function to pad legend item text to equal lengths. Refer to the [User Functions documentation]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/user-functions%}). |
| 58 | +1. Apply the function to each legend item to adjust alignment. Note that this option does not guarantee vertical stacking but may improve the layout. |
| 59 | + |
| 60 | +## See Also |
| 61 | + |
| 62 | +- [Graph Overview]({%slug telerikreporting/designing-reports/report-structure/graph/overview%}) |
| 63 | +- [User Functions]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/extending-expressions/user-functions%}) |
| 64 | +- [Non-breaking Space](https://en.wikipedia.org/wiki/Non-breaking_space) |
| 65 | + |
0 commit comments