ecGraph3D  -  Demo8

The VB code used to generate the above graph...

Public Sub Demo8(ecGraph3D1 As ecGraph3D)
  '3D surface function, custom tooltips, gradient background, multi-line text
  Dim i As Integer, j As Integer, z As Double, Title$
  Dim nX As Integer, nY As Integer, x0 As Single, y0 As Single, X1 As Single, Y1 As Single
  Dim zData() As Single, BarTooltips$(), AxisColor As Long
  With ecGraph3D1
    Call .Reset
    Title$ = "Demo 8 - 3D surface function, custom tooltips," + vbCrLf + _
             " gradient background, multi-line text"
    Call .AddText(Title$, 5, 2, , "font=Arial|bold|11")
    
    'MeshColorStyle: 0=color based on actual z value of the element,
                    '1=use maximum z value of the four corners of the mesh element
                    '2=use average z value of the four corners
                    '3=use mimimum z value of the four corners
    .MeshColorStyle = 0 '(0=actual, 1=max, 2-avr, 3=min)
    .PlotStyle = 3
    .Skirt = 0
                                        
    'set the background color to be a color gradient from blue to light blue at 120 degrees
    Call .SetBackground(vbBlue, ecLightBlue, 0, 120)
    
    'specify the aspect ratio: make y-axis longer and z-axis shorter
    Call .SetGraphShapeFactors(1.2, 1.2, 0.4)
    
    Call .ClearColorBands
    z = 0: Call .AddColorBand(z, ecBrown, ecBrown, Trim(Str(z)))
    z = 0.6: Call .AddColorBand(z, ecBrown, ecYellow, Trim(Str(z)))
    Call .SetzColorTableStyle(93, 40, 1.4, 50, vbBlack, "", vbBlack)
    
    'Customize the axes
    i = 50: AxisColor = RGB(i, i, i)
    Call .xAxisStyle(AxisColor, "x-axis", "", AxisColor, AxisColor)
    Call .yAxisStyle(AxisColor, "y-axis", "", AxisColor, AxisColor)
    Call .zAxisStyle(AxisColor, "z-axis", "", AxisColor, AxisColor)
    
    'Prepare data and tooltips arrays..
    x0 = 0: X1 = 50: nX = X1 - x0 + 1
    y0 = 0: Y1 = 50: nY = Y1 - y0 + 1
    ReDim zData(nX, nY), BarTooltips$(nX, nY)
    For i = 1 To nX
      For j = 1 To nY
        zData(i, j) = 0.25 * (1.1 - Cos(15 * Sqr((i / nX - 0.5) ^ 2 + (j / nX - 0.5) ^ 2))) ' + 5 * Rnd
        BarTooltips$(i, j) = "z = " + Format(zData(i, j), "0.000")
      Next j
    Next i
    
    Call .AddDataArray(nX, x0, X1, nY, y0, Y1, zData)
    Call .AddTooltips(BarTooltips$)
    
    Call .Refresh
  End With
End Sub
 


      Contents  (ecGraph3D.ocx)     Variables     Events     Properties     Functions     Subs

Copyright © 2008, Encore Consulting Pty Ltd