HOWTO: Use the UniformAxis Property to Control Chart Scaling
ID: Q194221
|
The information in this article applies to:
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
SUMMARY
When creating an XY Scatter chart using the MSChart control, the resulting
chart may appear distorted; that is, very tall and narrow or very short and
wide. This occurs on an XY Scatter chart whose axes have ranges that differ
by a large amount. For example, an X axis with a range of 0 - 10000 and a Y
axis of 0 - 50.
MORE INFORMATION
By default, the scale on the axes of an XY (Scatter) chart is uniform. If
the x-values are small in comparison to the y-values, or vice versa, the
chart may appear distorted. To allow the scaling of each axis to be
independent, change the UniformAxis property of the Plot object to False.
The default value of this property is True.
Step-by-Step Example
- Start Visual Basic and create a new Standard EXE project. Form1 is
created by default.
- Click Components from the Project menu and check the "Microsoft
Chart Control" component. The MSChart control is made available
on the Toolbox.
- Put an MSChart control on Form1.
- Copy and paste the following code to the form's code window:
Private Sub Form_Load()
Dim Graph(1 To 10, 1 To 2) As Single
Dim x As Integer
For x = 1 To 10
Graph(x, 1) = x ' value for X-axis
Graph(x, 2) = x * 10 ' value for Y-axis
Next x
MSChart1.chartType = VtChChartType2dXY ' set to X Y Scatter chart
MSChart1 = Graph ' populate chart's data grid using Graph array
' Leave the following line commented until step 6:
'MSChart1.Plot.UniformAxis = False
End Sub
- Press the F5 key to run the project. Note that the chart is not legible
(tall and narrow) because both x and y axes are using the same scale and
the y-values are larger than the x-values.
- Stop the project and remove the comment on the last line of code.
- Press the F5 key to run the project, and note that the chart is legible.
Additional query words:
graph appearance height width mschart.ocx kbVBp kbVBp500 kbVBp600
kbCtrl kbVBp kbdsd kbDSupport
Keywords : kbGrpVB
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbhowto