Results 1 to 7 of 7

Thread: MsChart - (X,Y)[REsolved]

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    51

    Resolved MsChart - (X,Y)[REsolved]

    Hi,

    I have values for X and Y. How To make a chart/grapgh out of it in MSChart? Because so far, all the examples that I see use only one value, which is X.

    Thanks
    Last edited by blackdevil1979; Oct 17th, 2004 at 11:11 PM.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Not sure where you are getting your values from (database?) but this is how I plot X and Y values on a Line Chart for my golf stats program. HTH

    VB Code:
    1. sSQL = "SELECT * FROM tblHandicap ORDER BY CompDate ASC"
    2. rsHandicap.Open sSQL, strCn, adOpenStatic, adLockOptimistic
    3.  
    4. ReDim arrHandicap(0 To rsHandicap.RecordCount - 1, 1 To 2)
    5.  
    6. For i = 0 To rsHandicap.RecordCount - 1
    7. arrHandicap(i, 1) = Format(rsHandicap!CompDate, "Short Date")  ' Horizontal Values
    8. arrHandicap(i, 2) = rsHandicap!NewHand ' Vertical Values
    9. rsHandicap.MoveNext
    10. Next i
    11.  
    12.  
    13. MSChart1.Title = "Title Of Your Graph"
    14. MSChart1.ChartData = arrHandicap 'Array Values
    15. MSChart1.chartType = VtChChartType2dLine 'Type of chart
    16.  
    17. rsHandicap.Close
    18. Set rsHandicap = Nothing

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    51

    Question MsCHart-(X,Y) continue

    Hi,

    Thanks.. even though it didnt show any difference between my chart and yours.. probably because the my Y value is very2 low. But how to set the scale?
    My Y value is between 0.00091491 to 0.01646844 and X Value is between (71,000.00) to 60,334.00. Currently my chart looks really2 small because the value of Y is less then 1.

    Thanks

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    To set the Max/Min values for your X and Y axis use the below code.

    VB Code:
    1. MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = YourValue
    2. MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = YourValue
    3.  
    4. MSChart1.Plot.Axis(VtChAxisIdX).ValueScale.Maximum = YourValue
    5. MSChart1.Plot.Axis(VtChAxisIdX).ValueScale.Minimum = YourValue

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved

    add the checkmark, and the word [RESOLVED] to the subject of your first post to resolve the thread

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    51

    Question

    Hi

    For i = 0 To iCount - 1
    Values(i, 1) = rs!X ' Horizontal Values
    Values(i, 2) = rs!Y ' Vertical Values
    rs.MoveNext
    Next i
    I received an error message: "OVERFLOW"
    Did you declared your arrHandicap as single?

    Thanks

  7. #7
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    I used the below to declare my array. Depending on how big/small your values are you might want to declare your array as Double.

    VB Code:
    1. Dim arrHandicap()

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