This article was previously published under Q178719
The MS Chart control can create an XY Scatter chart that you can use toplot X/Y coordinate data. This article shows you how to create a sampleprogram that displays X/Y coordinate data on a Scatter chart using the MSChart control.
You can create an XY Scatter chart by treating your data points as a two-dimensional grid. This grid comprised one or more data series. Each dataseries in the grid takes two columns and as many rows as you have datapoints. For example, the first and second columns make up the X and Ycoordinates of the first data series. The third and fourth columns make upthe X and Y coordinates of the second data series, and so on. The followingshows a sample grid. In this grid, the first data series is made up of thefollowing 10 data points:
1,2 2,4 3,6 4,8 5,10 6,12 7,14 8,16 9,18 10,20
The second data series is made up of the following 10 data points:
The next section shows how to create a sample project that demonstratesplotting X/Y coordinate data on a scatter chart.
This project assumes you added the MS Chart Component to the project. Theproject will plot the previously described data.
Start a new Standard EXE project in Visual Basic. Form1 is created by default.
Add a Chart control and a CommandButton to Form1.
In the MS Chart property window, click the Custom property ellipses button to display the property pages. On the Chart Tab, check XY (Scatter) for the Chart type.
Copy the following code to the Code window of Form1:
Private Sub Command1_Click() Dim x As Integer, y As Integer MSChart1.RowCount = 10 MSChart1.ColumnCount = 4 For y = 1 To 4 MSChart1.Column = y For x = 1 To 10 MSChart1.Row = x MSChart1.Data = x * y Next x Next y End Sub
Press the F5 key to run the program. Click the CommandButton and the data is plotted.
XY-Scatter x y kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport kbControl