This is a migrated thread and some comments may be shown as answers.

Showing only dates with values (autostep?)

3 Answers 144 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 09 Oct 2012, 03:16 PM
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();

3 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 11 Oct 2012, 02:42 PM
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.
0
Pablo
Top achievements
Rank 1
answered on 11 Oct 2012, 05:40 PM
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.

0
Accepted
Petar Kirov
Telerik team
answered on 16 Oct 2012, 07:55 PM
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.
Tags
Chart (Obsolete)
Asked by
Pablo
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Pablo
Top achievements
Rank 1
Share this question
or