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

Chart Without Any Padding Filling Up Grid's Content Area

6 Answers 96 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bardi
Top achievements
Rank 1
Bardi asked on 14 Dec 2013, 09:20 AM
Hi there,

I'm using a RadCartesianChart (using an AreaSeries) inside of a Grid. The problem I have is that I cannot make the chart fill the entire content area of the Grid's row that it is contained in. There is left/right padding. This can be seen in the attached "ontickspadded.png" where the PlotMode for the HorizontalAxis is "OnTicksPadded". When I change it to "BetweenTicks", it will have similar results.

I get rid of the left padding if I change the PlotMode to "OnTicks" but there are a few issues with this: 1) first data point is cut off, 2) first x-axis label is cut off and 3) there is still right padding. This can be seen in the attached "onticks.png".

What I'd like is for the chart to start and end without any padding on either side. I've roughly mocked up how I would like it to look on Paint in attached "idea.png".

This is the xaml for the chart:

<chart:RadCartesianChart x:Name="chart" Padding="0">
 
    <chart:RadCartesianChart.HorizontalAxis>
        <chart:CategoricalAxis FontSize="10" TickThickness="0" LineThickness="0" LabelFitMode="Rotate"  PlotMode="OnTicksPadded" />
    </chart:RadCartesianChart.HorizontalAxis>
 
    <chart:RadCartesianChart.VerticalAxis>
        <chart:LinearAxis Maximum="{Binding Location.Daily.Data[0].TemperatureMax}" Minimum="{Binding Location.Daily.Data[0].TemperatureMin}" Visibility="Collapsed"/>
    </chart:RadCartesianChart.VerticalAxis>
 
    <chart:RadCartesianChart.Series>
        <chart:AreaSeries Fill="Crimson" ShowLabels="True" StrokeMode="None">
            <chart:AreaSeries.PointTemplate>
                <DataTemplate>
                    <Ellipse Width="8" Height="8" Fill="White"/>
                </DataTemplate>
            </chart:AreaSeries.PointTemplate>
            <chart:AreaSeries.DataPoints>
            </chart:AreaSeries.DataPoints>
 
            <chart:AreaSeries.LabelDefinitions>
                <chart:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top">
                    <chart:ChartSeriesLabelDefinition.Template>
                        <DataTemplate>
                            <TextBlock Text="{Binding DataItem.LabelProperty}" Foreground="White" Margin="10,0,0,0" FontWeight="Bold" FontSize="12"/>
                        </DataTemplate>
                    </chart:ChartSeriesLabelDefinition.Template>
            </chart:ChartSeriesLabelDefinition>
             
            <chart:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top">
                <chart:ChartSeriesLabelDefinition.Template>
                    <DataTemplate>
                        <!--<TextBlock Text="{Binding DataItem.Value}" Foreground="Yellow" Margin="10,0,0,0"/>-->
                    </DataTemplate>
                </chart:ChartSeriesLabelDefinition.Template>
                </chart:ChartSeriesLabelDefinition>
            </chart:AreaSeries.LabelDefinitions>
 
            <chart:AreaSeries.CategoryBinding>
                <chart:PropertyNameDataPointBinding PropertyName="Category"/>
            </chart:AreaSeries.CategoryBinding>
            <chart:AreaSeries.ValueBinding>
                <chart:PropertyNameDataPointBinding PropertyName="Value"/>
            </chart:AreaSeries.ValueBinding>
 
        </chart:AreaSeries>
    </chart:RadCartesianChart.Series>
</chart:RadCartesianChart>

Any guidance would be much appreciated.

Many thanks.

Bardi

6 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 17 Dec 2013, 04:00 PM
Hello Bardi,

Thanks for writing.
You can set the LastLabelVisibility property of your horizontal axis to Clip. This way the chart will not consider the last label size when calculating its layout.
Please write again if you have other questions.

Regards,
Victor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Bardi
Top achievements
Rank 1
answered on 17 Dec 2013, 08:13 PM
Thanks for the reply Victor.

Unfortunately adding LastLabelVisibility=Clip to the HorizontalAxis doesn't appear to have made a difference - there is still padding to the left/right of the graph.
0
Victor
Telerik team
answered on 20 Dec 2013, 10:13 AM
Hi Bardi,

Please have a look at the attached app. Is this what you are looking for?
Please write again if you need further assistance.

Regards,
Victor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Bardi
Top achievements
Rank 1
answered on 20 Dec 2013, 10:22 AM
Thanks Victor for the sample code.

I ran it on 720p Emulator. The graph doesn't have any left/right padding, which is what I want. But the left and right-most x-axis labels are cutoff. I've attached a screenshot.

Bardi
0
Todor
Telerik team
answered on 27 Dec 2013, 08:34 AM
Hello Bardi,

I have modified the sample to include a custom style for the TextBlock which contains the labels. You can modify the margins of the custom style in order to achieve the desired location of the labels.

I hope this information helps.

Regards,
Todor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Bardi
Top achievements
Rank 1
answered on 29 Dec 2013, 06:36 AM
Thanks so much for that. Just what I was looking for!
Tags
Chart
Asked by
Bardi
Top achievements
Rank 1
Answers by
Victor
Telerik team
Bardi
Top achievements
Rank 1
Todor
Telerik team
Share this question
or