Results 1 to 7 of 7

Thread: Graph troubles again

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268

    Graph troubles again

    Hiya, just when I thought I had ms chart sussed too, sigh... :-)

    I need to be able to plot a line of best fit on my graph, is that possible? could anyone tell me how it's done?

    thanks for you time
    Ang

  2. #2
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    I don't know how. It sounds like statistical something or other. I'll ask brother who may know. In the mean time, go to this link and see if you can find something under Statistics that helps you.

    http://www.hoxie.org/math/title.htm

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    argh .. mschart ...

    i never had much success with that piece of crap ...

    you can always do what you asked for with an excel reference if that is an option for you ...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268
    how does that excel way work? that sounds handy

    i found a way to get a line of best fit, using least squares blah. Had to look back to my old school stats :-). But anyway, now i am able to get the formula into a string, now the next fun part will be getting that on the graph.

    stupid graphs :P
    Ang

  5. #5
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    I use the chart control and don't have problems with it. I just use it to display data though. In other words, the user can change the look and copy it to other applications, but I don't let them change values in the chart itself. It's read-only

  6. #6
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    You'll have to remove some of my function calls, but I'm leaving them in this code because the names are self-explanatory and it will help you see what I did better.
    VB Code:
    1. Public Function GraphQuery() As Long
    2. Dim i As Long
    3. Dim j As Long
    4. Dim RST As Recordset
    5. Dim iRecordcount As Long
    6. Dim iFieldCount As Long
    7.  
    8. On Error GoTo errHandler
    9.  
    10. Dim sData() As String
    11.  
    12. Set RST = DB.OpenRecordset(BASE_QUERY, dbOpenSnapshot)
    13. iRecordcount = CountRecords(RST)
    14. iFieldCount = RST.Fields.Count
    15.  
    16. If iFieldCount <= 0 Then Exit Function
    17.  
    18. If iRecordcount - 1 < 0 Then
    19.   MsgBox "No records to graph.", vbInformation, APP_TITLE
    20.   Exit Function
    21. End If
    22.  
    23. ReDim sData(iFieldCount - 1, iRecordcount - 1)
    24.  
    25. For i = 0 To iFieldCount - 1
    26.   For j = 0 To iRecordcount - 1
    27.     sData(i, j) = RST.Fields(i).Value
    28.     RST.MoveNext
    29.   Next j
    30.   RST.MoveFirst
    31. Next i
    32.  
    33. RecordsetClose RST
    34.  
    35. chtGraph.ChartData = sData
    36.  
    37. Exit Function
    38.  
    39. errHandler:
    40. GraphQuery = Err
    41.  
    42. End Function

  7. #7
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width