You can use `Environment.NewLine` and break up the text to wrap it inside the label. This can be done witout needing a custom renderer by inheriting `LabelFormatterBase<T>` and splitting up the long text into new lines.
Before getting started with this tutorial, please visit the [RadChart Axes Features LabelFormatter]({%slug axes-overview%}#common-axis-features) documentation to understand how to use a LabelFormatter.
In that documenation article's tutorial, the bound value for the axis was **DateTime**. Therefore, we needed to use `LabelFormatterBase<DateTime>` for the base class. In this example, the category value is a **string**, so we will change that to `LabelFormatterBase<string>`.
```csharp
public class LongTextLabelFormatter : LabelFormatterBase<string>
{
public override string FormatTypedValue(string text)
{
...
}
}
```
Now would be a good time to add extra properties that give you more flexibility. For example:
*`MaxLineLength` property to set the width of each line before a line break.
*`MaxLength` to set the overall maximum length.
```csharp
public class LongTextLabelFormatter : LabelFormatterBase<string>
{
public int MaxLineLength { get; set; } = 12;
public int MaxLength { get; set; } = 100;
public override string FormatTypedValue(string text)
{
...
}
}
```
Finally, in the `FormatTypedValue` method override, break up the text into several lines.
```csharp
public class LongTextLabelFormatter : LabelFormatterBase<string>
{
public int MaxLineLength { get; set; } = 12;
public int MaxLength { get; set; } = 100;
public override string FormatTypedValue(string text)
{
// Condition 1
// If the label text is less than the line length, just return it.
if (text.Length <= MaxLineLength)
return text;
// Condition 2
// If the text is longer than the desired line length, we need to split it into separate lines.
> You can use any text splitting logic you prefer, our example is based on [this StackOverflow answer](https://stackoverflow.com/a/16504017/1406210). The main takeaway is that the string is split up using `Environment.NewLine` or explicit `\r\n` characters, allowing it to fit in the label's bounds.
## Examples
### Axis Labels
To use this formatter class for axis tick labels, use it as an axis **LabelFormatter**. For example, here it is being used on a `CategoricalAxis`:
You can also use this same technique on series data point labels by setting the series **LabelFormatter** property. For example, here it is being used on a `SplineAreaSeries`: