Help with simple Month / Hit chart

Thread is closed for posting
2 posts, 0 answers
  1. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 21 Oct 2011 Link to this post

    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
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 26 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top