Super 2d/3d Graph Library

Enhance your .NET application adding nice charts within minutes! Save time and money!


Example 29: XYZ surface chart (using external formula function)

This sampe code will plot a surface chart in XYZ space.


Although you can feed manually the chart control with your own data, we use a seriesfactory object to generate a sample surface using the AddPoints method.
This method allows you to generate an array of points X, Y, Z, for a desired rectangle with a height for each point of the rectangle calculated by a function.

 

Steps:

1. Create a new Windows application project (VB.NET)

2. Add Super 2d/3d Graph Library to the toolbox pallete and drag it to Form1.

3. Copy and paste de following code:

Form Code
Imports Super2d3dGraphLibrary

Public Class Form1

' This function will generate a Y value for each x, z pair populated by the chart control
' You have complete freedom using this way to feed data to XYZ charts

Private Function y(ByVal x As Single, ByVal z As Single) As Single
   y = x * Math.Exp(-x ^ 2 - z ^ 2)

End
Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   ' Prepare the object that helps feeding data to chart control
   Dim sf As New SeriesFactory
   ' Auto-generate a mesh, from -2 to 2, step 0.2, using function y to calculate the y value for each x,z pairs.
   ' Think y coordinate as the height of the terrain and x, z as the west/north position
   sf.AddPoints(-2, 2, 0.2, -2, 2, 0.2, AddressOf y)

   With Super2d3dGraph1
      .AutoRefresh =
False
      .LicenseeIdentifier =
"PROF"
      .ShowDataTable =
False
      .ShowValues =
False
      .ShowLegend =
False
      .BackStyle = STYLEBACKGROUND.STYLEBACKGROUND_GRADIENT_TUBULAR_INVERTED
      .WallsBackStyle = STYLEWALLBACKGROUND.STYLEWALLBACKGROUND_TRANSPARENT

      ' Set chart style and apply data of the series factory object (sf)
      .Style = STYLE2D3D.STYLE3D_XYZ_SURFACE
      sf.ApplyTo(Super2d3dGraph1)

      ' Set some look and feel properties
      .SurfaceBrushStyle =
New SolidBrush(Color.LightGreen)
      .SetAllSeriesLineStyle(
New Pen(Color.Black))
      .ShowYAxis =
True
      .ShowXAxis =
True
      .ShowZAxis =
True
      .ShowDividersX =
True
      .ShowDividersZ =
True
      .XAxisDividersCount = 4
      .ZAxisDividersCount = 4
      .MarginRight = 40

      ' Paint chart
      .RefreshChart()

   End With

End Sub

' A little fun: show how to rotate the XYZ chart

Private Sub btRotate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btRotate.Click

   For yAngle As Single = 0 To Math.PI * 2 Step 0.1
      Super2d3dGraph1.YAxisAngle += 0.1
      Super2d3dGraph1.RefreshChart()
      Application.DoEvents()
   Next

End Sub

End Class



Result:


 

License & Purchase Info


Current version: 14

Super 2d/3d Graph Library is available as:
-Standard License (99€)
-Premium License (149€)
-Enterprise License (299€)

Click here for more details & purchase

Contact Info


Feel free to contact us
for questions related to any of our products or custom .Net development. We usually respond in the same labor day.

Software Siglo XXI

Main support service: support@softwaresigloxxi.com

Sales and other enquiries: contact@softwaresigloxxi.com