Incorrect bar positioning over x Axis

2 posts, 0 answers
  1. Ryan Benter
    Ryan Benter avatar
    3 posts
    Member since:
    Jul 2009

    Posted 10 Aug 2009 Link to this post


    I am creating a sales chart that will show daily sales within a period of time.

    So I have two RadCalendars one to choose the FROM date and another to choose the To date.

    I have a method that return all sales between the date selected on the FROM calendar and the date + 1 day of the TO calendar and then sets the item source for the RadChart like this:

      private void LoadSales(int _chatType, int _storeId)
                StoreSaleContext ctx = new StoreSaleContext();

                chtSalesChart.ItemsSource = ctx.StoreSales;

                ctx.Load(ctx.GetStoreSalesbyDateRangeQuery(_storId, Convert.ToDateTime(datePickerFrom.SelectedDate.Value.ToString()),             Convert.ToDateTime(datePickerTo.SelectedDate.Value.AddDays(1).ToString())));

                switch (_chatType)
                    case 1:
                    case 2:


    At this point everything works just fine.

    The problem is when I try to customize the X Axis to show a bar for each of the sales in a x Axis space.

    As you can see I have a SetCharBar method that looks like this:

         private void SetChartBar()

                chtSalesChart.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center;
                chtSalesChart.DefaultView.ChartTitle.Content = "Daily Sales";

                var seriesMapping = new SeriesMapping();
                seriesMapping.LegendLabel = "Daily Sales";
                seriesMapping.SeriesDefinition = new BarSeriesDefinition();

                var itemMapping = new ItemMapping("NetSales", DataPointMember.YValue);





    It works fine excepts for the CustomizeChartBars(); method:

     //Here is my issue
     private void CustomizeChartBars()
                chtSalesChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
                chtSalesChart.DefaultView.ChartArea.AxisX.AutoRange = false;
                chtSalesChart.DefaultView.ChartArea.AxisX.MinValue = datePickerFrom.SelectedDate.Value.ToOADate();
                chtSalesChart.DefaultView.ChartArea.AxisX.MaxValue = datePickerTo.SelectedDate.Value.ToOADate();
                chtSalesChart.DefaultView.ChartArea.AxisX.Step = DateTime.Today.AddDays(1).ToOADate() - DateTime.Today.ToOADate();
                chtSalesChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;

    As you can see I have set the min a max values to the FROM and TO RadCalendars respectively and 1 as the step.
    Notice also that max values is not + 1, this is because I just need that when retrieving the data from the database.

    Lets say I choose this range from 08/03/2009 to 08/07/009 The problem is  when I run it, what it shows at the Chart are only 4 sales when I have 5 and the bars are not at the center of the x space some of them use more than one x space.

    I tried changing the range like this: 08/03/2009 to 08/08/009 and it shows all the sales I have but obviously it adds another x space for Saturday and that's not what I want.

    Something else that is wrong  for example,  if I vary the range again like this: 08/01/2009 to 08/08/009 it shows all the sales but it starts at the 08/01/2009 and this is not correct.

    How can I customize the chart so sales will be shown at the date they were made and bars will use only one x space at the chart and not half and half like is doing now.

    Thanks in Advance for the your help

    The happy Lemur

  2. Velin
    Velin avatar
    391 posts

    Posted 13 Aug 2009 Link to this post

    Hello Ryan,

    Thank you for your feedback.

    Our developers will need some extra time to investigate the issue in details. In the meanwhile, we would suggest you to use the "categorical" X axis feature which is available with the Q2 version of RadChart. An article describing how to set up categorical chart is available here.

    Hope this will help.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top