Bars Overlapping

6 posts, 1 answers
  1. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 27 Sep 2011 Link to this post

    Hi, I'm having trouble with my bar charts using a large amount of data where the bars are overlapping. I have reproduced the error in a simple application using only 100 values. I am using version 2011.2.712.1040

    <Grid>
        <telerik:RadChart x:Name="ChartData">
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping>
     
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:BarSeriesDefinition ShowItemLabels="False" />
                    </telerik:SeriesMapping.SeriesDefinition>
     
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping DataPointMember="XValue" FieldName="Row" />
                        <telerik:ItemMapping DataPointMember="YValue" FieldName="Value" />
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
        </telerik:RadChart>
    </Grid>

    public class Data
    {
        public int Row { get; set; }
        public int Value { get; set; }
    }
     
    public partial class MainPage : UserControl
    {
        private Random _rand = new Random();
     
        public MainPage()
        {
            InitializeComponent();
     
            List<Data> data = GenerateData().ToList();
     
            ChartData.ItemsSource = data;
        }
     
        private IEnumerable<Data> GenerateData()
        {
            for (int i = 1; i < 100; ++i)
            {
                yield return new Data()
                {
                    Row = i,
                    Value = _rand.Next(400, 450)
                };
            }
        }
    }
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 28 Sep 2011 Link to this post

    Hi Brendan,

    This is an expected behavior of the Chart but unortunately not very readable. It is caused by the fact that you are trying to plot hundred bars on 100 XValues. However the Axis shows Label on each 20-th Value. You can manually reduce the Step so that all your bars are fully readable. This can be done by setting the AutoRange property to false and the MinValue, MaxValue and Step as 0, 100, 1 respectively.

    All the best,
    Evgenia
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 28 Sep 2011 Link to this post

    Why does the step size influence the bar widths? Only the ticks and labels should change position.

    I have dynamic amounts of data which may be anywhere from 1 - 20,000+ values, how do I know what step size is going to be correct?
  4. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 28 Sep 2011 Link to this post

    I've been playing around with the chart and it just doesn't seem to make sense why certain step sizes cause overlap. using 100 values I can us a step size of any where from 1 - 9 and the bar widths remain the same, however as soon as I use 10, they grow huge and overlap.

    Having a step of 10 for 100 values seems perfectly reasonable to me, I don't understand why the chart can't render it correctly. This is most definitely a bug.

    How are you calculating the bar widths?
  5. Answer
    Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 03 Oct 2011 Link to this post

    Hi Brendan,

    The width of the bars depends on the mechanism of calculating the ItemWidthPercent, as well as the number of ticks/length between ticks. Up until a specific point , the way it's calculated is based on a portion of the step, for example, if you have Step = 5 and ItemWidthPercent = 10, it'd mean that the width of the individual bar would be only 2% of the step ( i.e. 10% of 1/5th ). After that specific point the ItemWidthPercent is applied to the available space between two ticks, which is why the bars would become wider or thinner.
    The bigger your Step is  - the more clustered the bars will be. I still suggest that you decrease the Step to have a fully readable Chart.

    Greetings,
    Evgenia
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Brendan
    Brendan avatar
    34 posts
    Member since:
    Oct 2010

    Posted 03 Oct 2011 Link to this post

    Thank you for the explanation, I really appreciate the feedback. I will try to come up with something using this information
Back to Top