This is a migrated thread and some comments may be shown as answers.

Weird issue with chart layout

2 Answers 92 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Fabrice
Top achievements
Rank 1
Fabrice asked on 02 May 2016, 04:18 PM

I'm having this weird issue with the RadChartView when I try to use label rotation to try to improve label legibility, but it seems like a lot of space is being wasted. I'm only adding the following code:

axisX.LabelTemplate = (DataTemplate)Resources["tinyTemplate"];
// The following lines are commented to achieve the noRotation.png image
axisX.LabelRotationAngle = -45;
axisX.LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate;


<DataTemplate x:Key="tinyTemplate">
   <TextBlock FontSize="7pt"  Text="{Binding}" />
</DataTemplate>


axisX.LabelTemplate = (DataTemplate)Resources["tinyTemplate"];
axisX.LabelRotationAngle = -45;
axisX.LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate;

2 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 05 May 2016, 03:46 PM
Hello Fabrice,

Why don't you try to tweak the Margin property of the TextBlock inside your DataTemplate? Set it to negative value for the Top Margin and it will go up closer to the Horizontal Axis. We already have similar customizations in our online demos for example ChartView -> SmartLabels demo. You might see in code that we set the Top Margin to -2:

<DataTemplate x:Key="axisLabelTemplate">
        <TextBlock Text="{Binding Converter={StaticResource axisLabelConverter}}"
                           TextAlignment="Center"
                           Margin="0,-2,0,0"
                           Style="{StaticResource axisTextStyleMain}" />
    </DataTemplate>

Regards,
Evgenia
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Fabrice
Top achievements
Rank 1
answered on 09 May 2016, 02:55 PM
I have to confess the issue was on my side, my labels were being padded with spaces on the right (instead of "some code" i had "some code        "), so all I did was to add a converter that trimmed this text and the issue is now fixed. Thanks for the answer.
Tags
ChartView
Asked by
Fabrice
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Fabrice
Top achievements
Rank 1
Share this question
or