Bar chart is not using full height

3 posts, 1 answers
  1. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 09 Mar 2012 Link to this post

    Hello,

    I have a small problem left on a bar chart. The 2D bar chart is working fine exept is is not using it's full height potentional.
    (version Q2 2011)
    See attached image.

    XAML
    <telerik:RadChart
        x:Name="xxxxxxxxxx"
        Margin="0,0,1,14"
        HorizontalAlignment="Left"
        HorizontalContentAlignment="Left"
        VerticalAlignment="Top"
        VerticalContentAlignment="Top"
        Width="165"
        BorderBrush="Black"
        Background="Black" 
        Height="132">
        <telerik:RadChart.Resources>
            <Style x:Key="AxisXStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="WhiteSmoke" />
                <Setter Property="FontSize" Value="9" />
                <Setter Property="Height" Value="15" />
                <Setter Property="VerticalAlignment" Value="Top" />
            </Style>
            <Style x:Key="AxisXLineStyle" TargetType="Line">
                <Setter Property="Stroke" Value="Silver" />
                <Setter Property="Margin" Value="0,6,0,0" />
            </Style>
            <Style x:Key="LegendItemStyle" TargetType="telerik:ChartLegendItem">
                <Setter Property="Foreground" Value="WhiteSmoke" />
                <Setter Property="FontSize" Value="8" />
                <Setter Property="MarkerShape" Value="Square" />
            </Style>
            <Style x:Key="TopItemLabelStyle" TargetType="telerik:SeriesItemLabel">
                <Setter Property="FontSize" Value="7" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="Fill" Value="Black" />
            </Style>
            <Style x:Key="TopItemLabelStyle_XX" TargetType="telerik:SeriesItemLabel">
                <Setter Property="FontSize" Value="7" />
                <Setter Property="Background" Value="Black" />
                <Setter Property="Foreground" Value="White" />
            </Style>
        </telerik:RadChart.Resources>
        <telerik:RadChart.DefaultSeriesDefinition>
            <telerik:BarSeriesDefinition>
            </telerik:BarSeriesDefinition>
        </telerik:RadChart.DefaultSeriesDefinition>
        <telerik:RadChart.AnimationSettings>
            <telerik:AnimationSettings  />
        </telerik:RadChart.AnimationSettings>
        <telerik:RadChart.DefaultView>
            <telerik:ChartDefaultView>
                <telerik:ChartDefaultView.ChartTitle>
                    <telerik:ChartTitle Visibility="Collapsed" />
                </telerik:ChartDefaultView.ChartTitle>
                <telerik:ChartDefaultView.ChartArea>
                    <telerik:ChartArea Padding="5,0,6,0" IsTabStop="False" SmartLabelsEnabled="True" >
                        <telerik:ChartArea.Annotations >
                            <telerik:MarkedZone Background="Black" />
                        </telerik:ChartArea.Annotations>
                        <telerik:ChartArea.AxisX>
                            <telerik:AxisX Visibility="Collapsed" />
                        </telerik:ChartArea.AxisX>
                        <telerik:ChartArea.AxisY>
                            <telerik:AxisY Visibility="Collapsed" />
                        </telerik:ChartArea.AxisY>
                    </telerik:ChartArea>
                </telerik:ChartDefaultView.ChartArea>
                <telerik:ChartDefaultView.ChartLegend>
                    <telerik:ChartLegend Visibility="Collapsed" />
                </telerik:ChartDefaultView.ChartLegend>
            </telerik:ChartDefaultView>
        </telerik:RadChart.DefaultView>
    </telerik:RadChart>


    VB code
    Dim obj_Series As New SeriesMappingCollection
     
    xxxxxxxxxx.SeriesMappings.Clear()
    xxxxxxxxxx.ItemsSource = Nothing
     
    For i = 0 To 4
        Dim sm1 As New SeriesMapping()
        Dim d1 As New StackedBarSeriesDefinition()
     
        d1.ShowItemToolTips = True
        d1.ItemToolTipFormat = "#Y.Volume{#.00}"
        d1.ShowItemLabels = (i = 4)
        If i = 4 Then
            d1.SeriesItemLabelStyle = TryCast(Me.xxxxxxxxxx.Resources("TopItemLabelStyle"), Style)
            d1.ItemLabelFormat = "#STSUM"
            d1.LabelSettings.LabelDisplayMode = LabelDisplayMode.Outside
            d1.LabelSettings.Distance = 10
            d1.LabelSettings.ShowConnectors = False
        End If
        sm1.SeriesDefinition = d1
        sm1.SeriesDefinition.Appearance.Fill = New SolidColorBrush(Utils.StringToColor(mobj_xxxxxx_Colors(i)))
        sm1.LegendLabel = String.Empty
        sm1.CollectionIndex = i
        Dim im1 As ItemMapping = New ItemMapping
        im1.DataPointMember = DataPointMember.YValue
        sm1.ItemMappings.Add(im1)
        obj_Series.Add(sm1)
    Next
    xxxxxxxxxx.SeriesMappings = obj_Series

    How can I let the bar char use it's full height?

    Regards,

    Erik
  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 13 Mar 2012 Link to this post

    Hi Erik,

    The problem comes from the Y axis being collapsed initially. The axis uses an algorithm, which measures the available space to calculate its range and number of steps automatically. When it is collapsed the algorithm cannot be that precise (e.g. with data between 5 and 58 you may get a range of 0-100 with a step of 50, while knowing that there is enough space for 7 ticks you may get a refined range of 0-60 with a step of 10). So, please, leave the axis visible and hide it at a later stage or provide fixed values for min, max and step.

    In addition, the axis is auto-extended by a single step. Please, find out how to disable this in the following help topic:

    http://www.telerik.com/help/silverlight/radchart-features-axes-y-axis.html


    Best regards,
    Ves
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 14 Mar 2012 Link to this post

    Thanks Ves,

    That was the problem indeed. Hideing afterwards did not work (after rebinding a had a change) and gave the same result, but showing the Y-as and hiding the other ticks and stuff in de Y-as did the trick.

    Erik.
Back to Top