Personalized XAxis items

Thread is closed for posting
3 posts, 1 answers
  1. Quantesys IT
    Quantesys IT avatar
    21 posts
    Member since:
    Feb 2009

    Posted 07 Oct 2009 Link to this post

    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. Answer
    Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 07 Oct 2009 Link to this post

    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.
  3. Quantesys IT
    Quantesys IT avatar
    21 posts
    Member since:
    Feb 2009

    Posted 08 Oct 2009 Link to this post

    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.
Back to Top