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

Date on x-axis

2 Answers 242 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 24 Jun 2008, 01:50 PM
Hi,
I am creating a chart at runtime(on the click event of a button) on to a page. The x-axis, by default expects double values. But my requirement is to plot Date in the format 'MM/DD/YYYY' format. The CustomFormat option  is not working. May be  i have coded it wrong. This is my code. Please give necessary help. Thanks in advance.

 RadChart rChart = new RadChart();
rChart.PlotArea.XAxis.Appearance.CustomFormat = "MM/DD/YYYY";
            ChartSeries cSeries = new ChartSeries();
            cSeries.Name = "NewChart";
            ChartSeriesItem csItem1 = new ChartSeriesItem();
            csItem1.YValue = 10;
            csItem1.XValue = double.Parse("10/10/2002");
            ChartSeriesItem csItem2 = new ChartSeriesItem();
            csItem2.YValue = 20;
            csItem1.XValue = double.Parse("10/10/2003");
            ChartSeriesItem csItem3 = new ChartSeriesItem();
            csItem3.YValue = 30;
            csItem1.XValue = double.Parse("10/10/2004");
            ChartSeriesItem csItem4 = new ChartSeriesItem();
            csItem4.YValue = 40;
            csItem1.XValue = double.Parse("10/10/2005");
            ChartSeriesItem csItem5 = new ChartSeriesItem();
            csItem5.YValue = 50;
            csItem1.XValue = double.Parse("10/10/2007");

            cSeries.AddItem(csItem1);
            cSeries.AddItem(csItem2);
            cSeries.AddItem(csItem3);
            cSeries.AddItem(csItem4);
            cSeries.AddItem(csItem5);

           
            rChart.AddChartSeries(cSeries);


            placeHolder1.Controls.Add(rChart);

2 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 24 Jun 2008, 04:22 PM
Hello John,

We would suggest you to review this online example here that demonstrates how you can use DateTime data with the numerical axes of the RadChart control. The Appearance.ValueFormat / CustomFormat properties do not specify a custom format for parsing strings into doubles -- instead you need to pass a valid double value to the chart control via DateTime.ToOADate( ) method, then you can use the ValueFormat / CustomFormat properties to format the display of the double values that actually are your DateTime data values.

Hope this helps.


All the best,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
John
Top achievements
Rank 1
answered on 25 Jun 2008, 09:04 AM
Even though the example you gave didnt help me much... it paved the way for the successful enhancement :). Thanks a Lot Manuel.
Tags
Chart (Obsolete)
Asked by
John
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
John
Top achievements
Rank 1
Share this question
or