Platforms to show: All Mac Windows Linux Cross-Platform
/ChartDirector/surfaceprojection
Required plugins for this example: MBS ChartDirector Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /ChartDirector/surfaceprojection
This example is the version from Fri, 9th Feb 2023.
Project "surfaceprojection.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
EventHandler Sub Open()
// The x and y coordinates of the grid
Dim dataX() As Double = Array(0.0, 1, 2, 3, 4, 5, 6, 7, 8)
Dim dataY() As Double = Array(0.0, 1, 2, 3, 4, 5, 6, 7, 8)
Dim dataX_size As Integer = dataX.Ubound + 1
Dim dataY_size As Integer = dataY.Ubound + 1
// Use random numbers for the z values on the XY grid
Dim r As New CDRanSeriesMBS(11)
Dim dataZ() As Double = r.get2DSeries(dataX_size, dataY_size, 0.1, 1.9)
// Create a SurfaceChart object of size 680 x 580 pixels
Dim c As New CDSurfaceChartMBS(680, 580)
// Set the center of the plot region at (310, 280), and set width x depth x height to 320 x 320
// x 240 pixels
c.setPlotRegion(310, 280, 320, 320, 240)
// Set the elevation and rotation angles to 30 and 45 degrees
c.setViewAngle(30, 45)
// Set the data to use to plot the chart
c.setData(dataX, dataY, dataZ)
// Spline interpolate data to a 80 x 80 grid for a smooth surface
c.setInterpolation(80, 80)
// Use semi-transparent black (c0000000) for x and y major surface grid lines. Use dotted style
// for x and y minor surface grid lines.
Dim majorGridColor As Integer = &hc0000000
Dim minorGridColor As Integer = c.dashLineColor(majorGridColor, CDBaseChartMBS.kDotLine)
c.setSurfaceAxisGrid(majorGridColor, majorGridColor, minorGridColor, minorGridColor)
// Add XY projection
c.addXYProjection
// Set contour lines to semi-transparent white (&h7fffffff)
c.setContourColor(&h7fffffff)
// Add a color axis (the legend) in which the left center is anchored at (620, 250). Set the
// length to 200 pixels and the labels on the right side.
Call c.setColorAxis(620, 250, CDBaseChartMBS.kLeft, 200, CDBaseChartMBS.kRight)
// Set the x, y and z axis titles using 12 pt Arial Bold font
Call c.xAxis.setTitle("X Title<*br*>Placeholder", "Arial Bold", 12)
Call c.yAxis.setTitle("Y Title<*br*>Placeholder", "Arial Bold", 12)
call c.zAxis.setTitle("Z Title Placeholder", "Arial Bold", 12)
// 2x for higher DPI displays
c.setOutputOptions("bmpscale=2")
// Output the chart
pic = c.makeChartPicture
// drawn in paint event
End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
If pic <> Nil Then
// scale to window
g.DrawPicture pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height
End If
End EventHandler
Property pic As Picture
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS ChartDirector Plugin.