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

Personalized XAxis items

2 Answers 69 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Quantesys IT
Top achievements
Rank 1
Quantesys IT asked on 07 Oct 2009, 01:18 PM
Hello,

I'm working with RadChart control and I want to display the price evolution of an equity.

I can generate my Chart without problems with an XAxis based on the dateTime (converted with ToOADate method). My problem is that an equity is only traded during the opening periods of the market.

Is it possible to personalize the XAxis items to display only the item that I provide to the Chart?
Here is an example of data :

2009/09/10 ==> 23.4
2009/09/11 ==> 23.6
2009/09/14 ==> 23.2
2009/09/15 ==> 22.9

There is no data for the weekend (2009/09/12 and 2009/09/13) and I want that the chart display only the information about the open days without an approximation for the day without prices.

Thank you for your help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Schlurk
Top achievements
Rank 2
answered on 07 Oct 2009, 05:16 PM
When it comes to DateTime conversions like this, RadChart doesn't allow for anything but a solid range (aka, no gaps in the dates like you are describing) so from 1/1/2009 to 7/7/2009 every day or month (depending on what you do with your DateTime) would have to be included on the x-axis ( I learned this the hard way :[ ).

My suggestions would be to either style these days differently, or manually create your x-axis with integer values and then "mask" these by setting the text of each integer to the corresponding date. This way you can exclude whatever dates you would want to exclude.

I hope my above suggestions make sense.
0
Quantesys IT
Top achievements
Rank 1
answered on 08 Oct 2009, 01:13 PM
Thank you for your answer Schlurk,

I resolve my problem by following your suggestion and it works perfectly!

Here is a sample to illustrate the solution (based on a code found in another topic):

DataTable tbl = new DataTable();  
DataColumn col = new DataColumn("Value");  
col.DataType = typeof(int);  
tbl.Columns.Add(col);  
col = new DataColumn("Date");  
col.DataType = typeof(string);  
tbl.Columns.Add(col);  
col = new DataColumn("XColumn");  
col.DataType = typeof(double);  
tbl.Columns.Add(col);  
 
tbl.Rows.Add(new object[] { 5, DateTime.Today.ToString("yyyy-MM-dd"), 1 });  
tbl.Rows.Add(new object[] { 4, DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"), 2 });  
tbl.Rows.Add(new object[] { 3, DateTime.Today.AddDays(3).ToString("yyyy-MM-dd"), 3 });  
tbl.Rows.Add(new object[] { 6, DateTime.Today.AddDays(4).ToString("yyyy-MM-dd"), 4 });  
tbl.Rows.Add(new object[] { 3, DateTime.Today.AddDays(6).ToString("yyyy-MM-dd"), 5 });  
tbl.Rows.Add(new object[] { 6, DateTime.Today.AddDays(8).ToString("yyyy-MM-dd"), 6 });  
 
ChartSeries ser = new ChartSeries("Price");  
ser.Type = ChartSeriesType.Line;  
ser.DataYColumn = "Value";  
ser.DataXColumn = "XColumn";  
rcTest.Series.Add(ser);  
 
rcTest.PlotArea.XAxis.AutoShrink = false;  
rcTest.PlotArea.XAxis.AutoScale = true;  
rcTest.PlotArea.XAxis.IsZeroBased = false;  
 
// Personalized labels  
rcTest.PlotArea.XAxis.DataLabelsColumn = "Date";  
 
rcTest.DataSource = tbl;  
rcTest.DataBind(); 

Thank you for your help.
Tags
Chart (Obsolete)
Asked by
Quantesys IT
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Quantesys IT
Top achievements
Rank 1
Share this question
or