Showing only dates with values (autostep?)

Thread is closed for posting
4 posts, 1 answers
  1. Pablo
    Pablo avatar
    2 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2012 Link to this post

    Hello Telerik Community:

    I have the following issue, using the following code I get the results shown in the attached image.

    Is there anyway to autostep or show only the dates that have some value on them?

    Thanks in advance!


    //OADate column for chart:
     
     DataColumn col = new DataColumn("OADate", typeof(System.Double));
     dtable.Columns.Add(col);
     
    //Converting SQL Datetime values to OADate column
     
     int b = 0;
     foreach (DataRow row in dtMerArrCru.Rows)
     {
         row["OADate"] = Convert.ToDateTime(dtable.Rows[b][1]).ToOADate();
         b++;
     }
     
    //Formatting chart:
     
     RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;
     RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "MM/dd/yyyy";
     RadChart1.PlotArea.XAxis.IsZeroBased = false;
     RadChart1.PlotArea.XAxis.AutoScale = false;
     
     RadChart1.PlotArea.XAxis.AddRange(Convert.ToDouble(dtMerArrCru.Rows[0]["OADate"]),     Convert.ToDouble(dtMerArrCru.Rows[dtMerArrCru.Rows.Count - 1]["OADate"]), 1);
     
     RadChart1.DataGroupColumn = "Type";
     RadChart1.DataManager.ValuesXColumn = "OADate";
     RadChart1.DataManager.ValuesYColumns = new string[] { "Quantity" };
     RadChart1.DataSource = dtable;
     RadChart1.DataBind();
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 11 Oct 2012 Link to this post

    Hello Pablo,

    The problem is that when you are setting manual range of x axis (using the AddRange() method), you are setting a step of 1 - which means one day in the OADate format. You probably have a wide range on the x axis, meaning you get a lot of labels (one label per each day).

    Here are some options you can try:
    • Use a bigger step
    • Use XAxis.DataLabelsColumn binding and not chartSeries.DataXColumn binding (the 2 binding are incompatible with each other). By using only  DataLabelsColumn binding, the chart will create a label per each data point and will position the data points on equal distance between each other. 

    Kind regards,
    Petar Kirov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pablo
    Pablo avatar
    2 posts
    Member since:
    Oct 2012

    Posted 11 Oct 2012 Link to this post

    The second option is what suits my needs.

    I have made the following changes to the code:

    //RadChart1.PlotArea.XAxis.AddRange(Convert.ToDouble(dtMerArrCru.Rows[0][3]), Convert.ToDouble(dtMerArrCru.Rows[dtMerArrCru.Rows.Count - 1][3]), 1);
                RadChart1.DataGroupColumn = "Tipo";
                //RadChart1.DataManager.ValuesXColumn = "OADate";
                RadChart1.PlotArea.XAxis.DataLabelsColumn = "OADate";
                RadChart1.DataManager.ValuesYColumns = new string[] { "Cuantos" };


    The dates on the Xaxis are fine, also the quantity,  however the bars on the chart are distribuited wrong.. Maybe the Yaxis also needs DataLabelsColumn or the DatagroupColumn?

    On the files attached is the data for the chart, as well as the result I get with the changes.

    Proper bar placement and I will be all set.

  5. Answer
    Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 16 Oct 2012 Link to this post

    Hi Pablo,

    I apologize for not seeing this before, but the DataLabelsColumn setting is only applicable when the X-values of the different series match perfectly. In your case the data points don't have any x value assigned. So the items from the "Arribos" series are positioned on the first 25 slots and the items from the "Cruces" series are positioned on the first 10 slots.

    One possible solution to this is to manually create the series, and their items. I have attached a project demonstrating this.

    Regards,
    Petar Kirov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top