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

Help with simple Month / Hit chart

1 Answer 36 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Alan T
Top achievements
Rank 1
Alan T asked on 21 Oct 2011, 04:22 PM
I've reviewed the examples on the site and it's all a bit over my head. 

I've got a table called 'hits' in my database that simply stores the id of the item the hit is related to (in this case a property) and the time of the hit. 

What i want to do is have the months along the x-axis of my chart, and the number of hits on the y-axis.

At the moment i'm returning these from my database in a List(Of hit) where hit is a custom class i've written to store the hit information.

Can someone talk me through, or direct me towards an example on how to achieve this. 

At the moment i've got something like this:

For Each obj_hit As hit In hits 
            If Month(hit.date_created) = 1 Then 'jan
  
            ElseIf Month(hit.date_created) = 2 Then 'feb
  
            ElseIf Month(hit.date_created) = 3 Then 'march
  
            ElseIf Month(hit.date_created) = 4 Then '..
  
            ElseIf Month(hit.date_created) = 5 Then
  
            ElseIf Month(hit.date_created) = 6 Then
  
            ElseIf Month(hit.date_created) = 7 Then
  
            ElseIf Month(hit.date_created) = 8 Then
  
            ElseIf Month(hit.date_created) = 9 Then
  
            ElseIf Month(hit.date_created) = 10 Then
  
            ElseIf Month(hit.date_created) = 11 Then
  
            ElseIf Month(hit.date_created) = 12 Then
  
            End If
Next

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 26 Oct 2011, 01:09 PM
Hello Alan T,

You may use this help topic as a guide on how to bind RadChart to a List of Business Objects. You may set your XValues to be DateTimes but formatted so that you see only the Month name. For the purpose have in mind that XValue requires its values to be of float type. That's why DateTime values should be converted to their OLE Automation equivalents using ToOADate(). RadChart.XAxis.Appearance.ValueFormat property provides means to format X axis labels. In this case it is set to ShortDate and the CustomFormat to "MMM".
You can set custom axis range after setting AutoScale property of the axis to false. With the step of 30 days you'll be able to see months per Axis Item Label.
Refer to this demo which can help you with your scenario.

All the best,
Evgenia
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
Alan T
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or