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


    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.

            <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 x:Key="AxisXLineStyle" TargetType="Line">
                <Setter Property="Stroke" Value="Silver" />
                <Setter Property="Margin" Value="0,6,0,0" />
            <Style x:Key="LegendItemStyle" TargetType="telerik:ChartLegendItem">
                <Setter Property="Foreground" Value="WhiteSmoke" />
                <Setter Property="FontSize" Value="8" />
                <Setter Property="MarkerShape" Value="Square" />
            <Style x:Key="TopItemLabelStyle" TargetType="telerik:SeriesItemLabel">
                <Setter Property="FontSize" Value="7" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="Fill" Value="Black" />
            <Style x:Key="TopItemLabelStyle_XX" TargetType="telerik:SeriesItemLabel">
                <Setter Property="FontSize" Value="7" />
                <Setter Property="Background" Value="Black" />
                <Setter Property="Foreground" Value="White" />
            <telerik:AnimationSettings  />
                    <telerik:ChartTitle Visibility="Collapsed" />
                    <telerik:ChartArea Padding="5,0,6,0" IsTabStop="False" SmartLabelsEnabled="True" >
                        <telerik:ChartArea.Annotations >
                            <telerik:MarkedZone Background="Black" />
                            <telerik:AxisX Visibility="Collapsed" />
                            <telerik:AxisY Visibility="Collapsed" />
                    <telerik:ChartLegend Visibility="Collapsed" />

    VB code
    Dim obj_Series As New SeriesMappingCollection
    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
    xxxxxxxxxx.SeriesMappings = obj_Series

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


  2. Answer
    Ves avatar
    2916 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:

    Best regards,
    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. 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.

Back to Top