Scrolling problem

Thread is closed for posting
2 posts, 0 answers
  1. Salma
    Salma avatar
    5 posts
    Member since:
    Mar 2011

    Posted 04 Apr 2011 Link to this post

    Please I'm trying to do scrolling for the data that I have but it is throw an error here
    TelerikHourlyChart.Series[0].Items.AddRange(items);
    how can I do scrolling?

      private void CreateTelerikChart(Usage usage)

            {

     

              

                try

                {

     

     

         

                    TelerikHourlyChart.Legend.Visible = false;

                    TelerikHourlyChart.ChartTitle.Visible = false;

                    TelerikHourlyChart.Series[0].Items.Clear();

                    TelerikHourlyChart.Series[1].Items.Clear();

                   

     

     

     

     

                    TelerikHourlyChart.Series[0].Appearance.BarWidthPercent = 90;

                    TelerikHourlyChart.Series[0].Appearance.ExplodePercent = 20;

     

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Width.Value = 726;

              

                    TelerikHourlyChart.PlotArea.Appearance.FillStyle.MainColor = Color.White;

                    TelerikHourlyChart.PlotArea.Appearance.FillStyle.SecondColor = Color.White;

     

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Margins.Left.Value = 10;

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Margins.Right.Value = 5;

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Margins.Top.Value = 5;

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Paddings.Top.Value = 5;

                    TelerikHourlyChart.PlotArea.Appearance.Dimensions.Margins.Bottom.Value = 10;

     

                    TelerikHourlyChart.PlotArea.YAxis.LabelStep = 1;

                    TelerikHourlyChart.PlotArea.Appearance.Border.Color = Color.Transparent;

                    TelerikHourlyChart.PlotArea.YAxis.AxisLabel.Visible = true;

                                

               

                    List<HourlyUsage> hourlyUsages = HourlyUsage.GetHourlyUsages(usage);

              

                    DateTime hourTime = DateTime.Today.AddHours(0);

                    TelerikHourlyChart.PlotArea.XAxis.Items.Clear();

                    TelerikHourlyChart.Series[0].Items.Clear();

                    decimal totalUsage = 0;

                    decimal totalCost = 0;

                    decimal maxUsage = hourlyUsages.MaximumUsage();

                 

                    string unavailableMsg = "Data is not available.";

                    bool istrue = false;

     

                    if (usage != null && usage.UsageIntervals != null && usage.UsageIntervals.Count > 0)

                    {

     

                        int index = 0;

                        istrue = System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(usage.StartDate.DateWithOutTime());

                        int year = int.Parse(usage.StartDate.Year.ToString());

                        int IslightSavingTime = System.TimeZone.CurrentTimeZone.GetDaylightChanges(year).Start.Hour;// DateTimeInstance.IsDaylightSavingTime();

                        TelerikHourlyChart.PlotArea.XAxis.AutoScale = false;

                        TelerikHourlyChart.PlotArea.YAxis.AutoScale = false;

                        TelerikHourlyChart.PlotArea.XAxis.LabelStep = 3;

                        decimal labelOffset = maxUsage * (decimal)1.25;

     

                        TelerikHourlyChart.PlotArea.YAxis.MaxValue = double.Parse(labelOffset.ToString());

                      int count = hourlyUsages.Count;

     

                     ChartSeriesItem[] items = new ChartSeriesItem[count];

                        DataTable dt = new DataTable();

                        dt.Columns.Add(new DataColumn("MyColumn", typeof(ChartSeriesItem)));

                        foreach (HourlyUsage hu in hourlyUsages)

                        {

     

     

     

                            hourTime = hu.HourTime;

                            decimal point = hu.AdjustedUsage;

                            decimal cost = hu.Cost;

                          

                            decimal AdjustedUsage = hu.AdjustedUsage;

                            decimal UnAdjustedUsage = hu.UnAdjustedUsage;

     

                            totalUsage += point;

                            totalCost += cost;

     

                            Color selected = new Color();

                            Color selectedGradient = new Color();

                            if (hu.AdjustedUsage == 0)

                            {

                                selected = Color.Transparent;

                                selectedGradient = Color.Transparent;

                            }

                            else

                            {

                         int hour = hu.HourTime.Hour;

                          

     

                             items[index] = new ChartSeriesItem(double.Parse(point.ToString()), index );

                        

                               DataRow dr = dt.NewRow();

                               dr[0] = items[index];

                              dt.Rows.Add(dr);

                                index++;

                              

                            }

     

     

     

     

                        }

                        int daycount = usage.UsageIntervals.Count;

                        int counthour;

                        if (chkshow15.Checked)

                        {

     

     

                            TelerikHourlyChart.ClientSettings.EnableZoom = false;

                            TelerikHourlyChart.ClientSettings.XScale = 24;

     

                            TelerikHourlyChart.ClientSettings.ScrollMode = Telerik.Web.UI.ChartClientScrollMode.XOnly;

                           

         

                            TelerikHourlyChart.Series[0].Items.AddRange(items);

                            TelerikHourlyChart.DataBind();

     

     

                            TelerikHourlyChart.DataSource = dt;

                            TelerikHourlyChart.DataBind();

     

                        }

                    }

     

                    }

     

                }

                catch (Exception ex)

                {

                }

     

               

            }

     

  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 06 Apr 2011 Link to this post

    Hello Salma,

    Thank you for contacting Telerik Support and for the code provided.

    However, it is hard to replicate the exact issue from these fragments. I prepared a sample project which illustrates how to setup Scrolling functionality in RadChart and to set DateTime values for the X Axis. Please, note that you need to convert the DateTime values to their OLE Automation equivalents using ToOADate(). You can find the example here.

    In case that the sample does not meet your requirements, could you please modify it to replicate the unwanted behavior or submit another working project which demonstrates it. Thus we will provide more straight-to-the-point solution.


    Regards,
    Giuseppe
    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
Back to Top