Microsoft KB Archive/85264

= VB Graph: Use XPosData to Plot Fractional X-Axis Values =

Article ID: 85264

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q85264



SUMMARY
You can use the Graph custom control (GRAPH.VBX) XPosData property to give independent X-axis values for graphs. That is, the graph is not forced to plot on the X-axis, and has the ability to plot fractional data points between X-axis values. This property can be used with all graphs types except pie.



MORE INFORMATION
By default, graphs use a dependent X-axis scale. This means data points plotted conform to the whole-number increments shown on the X- axis. To plot fractional X-axis values, use the XPosData property. The XPosData values are set for each data point, allowing fractional X-axis plotted values to appear in the graph. XPosData sets the X coordinate, and GraphData sets the Y coordinate. The example below demonstrates this by plotting three different data points on a scatter graph:

Example
 Run Visual Basic, or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. From the File menu, choose Add File. In the Files box, select the GRAPH.VBX custom control file. The GRAPH tool appears in the Toolbox. Place a Graph (Graph1) on Form1 by double-clicking the Graph tool in the Toolbox. In the Properties box, set the following properties for Graph1:

 AutoInc = 0 (Off) GraphType = 9 (Scatter) NumPoints = 3</li> SymbolData = 3 (Solid triangle - up)</li></ul> </li>  Add the following code to Form1: Sub Form_Load

Graph1.ThisPoint = 1  'This indicates which datapoint to work on      Graph1.GraphData = 10  'This sets the Y-axis value for this point Graph1.XPosData = .2  'This sets the X-axis value for this point

Graph1.ThisPoint = 2 Graph1.GraphData = 5 Graph1.XPosData = 1.3

Graph1.ThisPoint = 3 Graph1.GraphData = 3 Graph1.XPosData = 2.4

End Sub </li> Press F5 to run the code.</li></ol>

This example, when run, plots three data points in (X,Y) format. In this case, XPosData is used to provide non-integer X-axis values. The three triangles are plotted using the following coordinates:

(.2, 10), (1.3, 5), (2.4, 3)

XPosData works for other graph types too, except pie, for which X-axis data has no meaning. To try this example with another graph type, change the GraphType property of Grid1 to &quot;4 - 3D Bar&quot;. Notice how the bars orient against the X-axis when you run the code.

Additional query words: 2.00 3.00

Keywords: KB85264

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.