Solved

xy scatter plot in MSchart

Posted on 1998-06-25
4
2,489 Views
Last Modified: 2008-02-01
I'm trying to produce a simple y vs x plot a la Excel with MSChart. The x and y data  are in the same array and all I want to do is plot y vs. x with a linear scale on both axes. THis should be easy but I can't get it to work.
0
Comment
Question by:lberan
  • 4
4 Comments
 

Accepted Solution

by:
Nazmi earned 50 total points
ID: 1464270
Dear Iberan,
It is very easy to plot x vs y. I recommend you define your chart on run time.
First of all choose MS Chart Common Controls object and define it on a form (MSChart1).
Afterwards try to locate your x and y values in a data file such as Data.dat
Now, you can write a code to open data file and read x and y values.

    Dim rowCount As Integer
    Dim columnCount As Integer
    Dim DataGrid As DataGrid

MSChart1.chartType = VtChChartType2dX
MSChart1.SeriesType = VtChSeriesType2dXY

                   Open "c:\Data.dat" For Input As #1
            With MSChart1.DataGrid
            rowCount = 4
            columnCount = 5
            .SetSize RowLabelCount, ColumnLabelCount, _
            rowCount, columnCount
         
            For i = 1 To rowCount
                Input #1, X, Y
                .SetData i, 1, X, 0                
                .SetData i, 2, C1, 0
               
            Next i
        End With
                      Close #1
       
   
    With MSChart1.Plot
       
        .UniformAxis = True
        .LocationRect.Max.Y = 5500
        .LocationRect.Min.Y = 0
        .LocationRect.Max.X = 10000
        .LocationRect.Min.X = 800
        .Axis(VtChAxisIdY).AxisTitle.Visible = True
        .Axis(VtChAxisIdX).AxisTitle.Text = "I am X-Axis"
        .Axis(VtChAxisIdY).AxisTitle.Text = "I am Y-Axis"

Now your chart is OK
       
0
 

Expert Comment

by:Nazmi
ID: 1464271
If you have any trouble mail me please:
nazmi@arcelik.com.tr
0
 

Expert Comment

by:Nazmi
ID: 1464272
Sorry.. Please correct C1 as Y.. and please add these lines to the definition block :
Dim Y As Double
Dim X As Double
0
 

Expert Comment

by:Nazmi
ID: 1464273
Dear Iberan,
Why haven't you evaluate, I mean give a point, my answer?
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 78
Prevent checkbox click event occur while editing it in vb6 8 48
Add and format columns in vb6 7 58
Export Data to Different .csv Files 26 105
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question