Weird issue with chart layout

3 posts, 1 answers
  1. Fabrice
    Fabrice avatar
    22 posts
    Member since:
    Jan 2015

    Posted 02 May Link to this post

    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. Answer
    Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 05 May Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Fabrice
    Fabrice avatar
    22 posts
    Member since:
    Jan 2015

    Posted 09 May in reply to Evgenia Link to this post

    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.
Back to Top