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

Need help with simple line chart

3 Answers 80 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
esw00
Top achievements
Rank 1
esw00 asked on 24 Jun 2010, 08:54 PM
I have a stored procedure that selects two columns from a single table - size (int) and date.  All I want to do is plot a line graph with the size, and have the X axis item labels show the dates recorded.

So, the data looks like this:
 
size | date 
224 | 1-5-10 
250 | 1-10-10 
156 | 1-22-10 

And this is what I ended up with when I tried to use the Wizard (bound to a SqlDataSource):

 <telerik:RadChart ID="RadChart1" runat="server" DataSourceID="SqlDataSource1"  
                    DefaultType="Line" Skin="Default"
                    <Series> 
                        <telerik:ChartSeries Name="Size" DataYColumn="size" Type="Line"  
                            DataXColumn="size"
                            <Appearance> 
                                <FillStyle MainColor="213, 247, 255"
                                </FillStyle> 
                            </Appearance> 
                        </telerik:ChartSeries> 
                    </Series> 
                    <PlotArea> 
                        <XAxis AutoScale="False" DataLabelsColumn="size"
                            </XAxis> 
                    </PlotArea> 
                </telerik:RadChart> 

What I want is to have the dates as the X axis labels, but I can't figure out how to do it.  It seems like this should be incredibly simple, but I just find the chart syntax really confusing.  Any help would be very much appreciated.



3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 29 Jun 2010, 01:48 PM
Hello,

For the sake of completeness I have pasted my reply, provided in the support ticket you have started on the same topic:

Please, find attached a small example, showing a graph similar to the one you have described. Several notes on it:
  • RadChart does not support directly DateTime values. It supports the OLE Automation date equivalent (obtained through DateTime.ToOADate() method).
  • The value of DataYColumn property defines the column, which will provide the values for the YValue of each ChartSeriesItem. The value of DataXColumn property defines the column, which will provide the XValue of each ChartSeriesItem. The XValue defines the position of the item along the XAxis, so the above setup allows you to have unevenly positioned items in the graph (shown in the example).
  • XAxis - it is numeric and by default starts from 0, so you must set IsZeroBased to false in order to show only the period of time you are interested in and not starting from 0 (which is 31/12/1899 in OLE Automation date).
  • Finally -- how to achieve this with SqlDataSource? Here is an example of a query, which converts DateTime values to double:
"SELECT [Size], CAST([Date] AS FLOAT) + 2 as float_date FROM [Table_1]"

With this query, you will need to set the DataXColumn property to "float_date".



Best regards,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Maithree
Top achievements
Rank 1
answered on 07 Dec 2010, 02:41 PM
SELECT Place,pH, CAST([RecordedDate] AS FLOAT) + 2  as RecordedDate FROM [AnalysisRecords] ...I casted my datetime field like this,also set

ValueFormat

 

="ShortDate"  for the Appearacnce of X- axis

 

 but this does'nt show the correct datetime values as in my data base...Please help..i want to plt a time scale on the x- axis
0
Ves
Telerik team
answered on 09 Dec 2010, 05:24 PM
Hello Maithree,

I am afraid this information would not allow us to pinpoint the issue. Please, add a DataGrid  next to RadChart and populate it with the same datasource. The RecordedDate column should contain numbers around 40000 for DateTime values within 2000 to 2010. If that is correct, please, send us a small example, we will investigate it and get back to you with our findings.

Best regards,
Ves
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Chart (Obsolete)
Asked by
esw00
Top achievements
Rank 1
Answers by
Ves
Telerik team
Maithree
Top achievements
Rank 1
Share this question
or