"0"-value Label on Bar Chart

3 posts, 1 answers
  1. Volodya Bychko
    Volodya Bychko avatar
    10 posts
    Member since:
    May 2010

    Posted 28 Oct 2010 Link to this post

    Hello Telerik!

    I have following xaml code:
    <UserControl x:Class="SilverlightApplication8.CategoryBarZoom"
        mc:Ignorable="d" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" d:DesignHeight="300" d:DesignWidth="400">
     
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadChart x:Name="RadChart1"></telerik:RadChart>
        </Grid>
    </UserControl>

    and c# code:
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Controls;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Controls.Charting;
     
    namespace SilverlightApplication8
    {
        public partial class CategoryBarZoom
        {
            public CategoryBarZoom()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(CategoryBarZoom_Loaded);
            }
     
            void CategoryBarZoom_Loaded(object sender, RoutedEventArgs e)
            {
                RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
     
                this.SetMappings(RadChart1);
                RadChart1.ItemsSource = new List<MyData>() {
                    new MyData("Name1", 0),
                    new MyData("Name2", 15),
                    new MyData("Name3", 0),
                    new MyData("Name4", 0),
                    new MyData("Name5", 5),
                    new MyData("Name6", 35),
                    new MyData("Name7", 5),
                    new MyData("Name8", 25),
                    new MyData("Name9", 5),
                    new MyData("Name10", 25),
                    new MyData("Name11", 5)
                };
            }
     
     
            private void SetMappings(RadChart chart)
            {
                SeriesMapping seriesMapping = new SeriesMapping();
                seriesMapping.SeriesDefinition = new BarSeriesDefinition();
                (seriesMapping.SeriesDefinition as BarSeriesDefinition).LabelSettings.ShowZeroValueLabels = true;
                ItemMapping itemMapping = new ItemMapping();
                itemMapping.DataPointMember = DataPointMember.YValue;
                itemMapping.FieldName = "Value";
                seriesMapping.ItemMappings.Add(itemMapping);
                itemMapping = new ItemMapping();
                itemMapping.DataPointMember = DataPointMember.XCategory;
                itemMapping.FieldName = "Name";
                seriesMapping.ItemMappings.Add(itemMapping);
                chart.SeriesMappings.Add(seriesMapping);
            }
        }
     
        public class MyData
        {
            public double Value { get; set; }
            public string Name { get; set; }
     
            public MyData(string name, double value)
            {
                this.Name = name;
                this.Value = value;
            }
        }
    }

    My problem is the next: how I can display zero value label when I use BarSeriesDefinition?
    I tried to use property ShowZeroValueLabels for BarSeriesDefinition, but this didn't resolved my problem. ShowZeroValueLabels property works fine for HorizontalBarSeriesDefinition, but for BarSeriesDefinition I can't display label for item when it has zero value.

    Could You help me please resolve my problem: display label for item with "0" value?

    Please help me,
    Volodya.
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    397 posts

    Posted 01 Nov 2010 Link to this post

    Hello Volodya Bychko,

    We are aware of this issue. Currently the zero value labels are positioned below the X axis, if you extend the Y axis range to a negative number they would be visible.Our developers have already addressed this limitation and as of our official 2010.Q3 release, scheduled for mid-November, the zero value labels would be correctly positioned above the X axis.

    Best wishes,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Volodya Bychko
    Volodya Bychko avatar
    10 posts
    Member since:
    May 2010

    Posted 01 Nov 2010 Link to this post

    Hello,

    Thanks for answer. We hope what this issue wasn't appear in future.

    Best Regard, 

    Volodya.             

Back to Top