Example: /ChartDirector/surfacecolor

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/ChartDirector/surfacecolor


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/surfacecolor

This example is the version from Fri, 9th Feb 2023.

Project "surfacecolor.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() For i As Integer = 0 To 3 createChart i Next End EventHandler
Sub createChart(chartIndex as integer) // The x and y coordinates of the grid Dim dataX() As Double = Array(-4.0, -3, -2, -1, 0, 1, 2, 3, 4) Dim dataX_size As Integer = dataX.Ubound + 1 Dim dataY() As Double = Array(-4.0, -3, -2, -1, 0, 1, 2, 3, 4) Dim dataY_size As Integer = dataY.Ubound + 1 // Use random numbers for the z values on the XY grid Dim r As New CDRanSeriesMBS(99) Dim dataZ() As Double = r.get2DSeries(dataX_size, dataY_size, -0.9, 0.9) // Create a SurfaceChart object of size 460 x 460 pixels with white (&hffffff) background and // grey (&h888888) border Dim c As New CDSurfaceChartMBS(460, 460, &hffffff, &h888888) // Set the surface data c.setData(dataX, dataY, dataZ) // Add a color axis (the legend) in at the top center of the chart, with labels at the bottom. // Set the axis to flat style. Dim cAxis As CDColorAxisMBS = c.setColorAxis(c.getWidth / 2, 15, CDBaseChartMBS.kTop, 250, CDBaseChartMBS.kBottom) Call cAxis.setTitle("Color Axis") cAxis.setAxisBorder(CDBaseChartMBS.kTransparent, 0) // By default, the color axis is synchronized with the z-axis. The following code remove the // synchronization so that the color axis will auto-scale independently. Set the auto-scale // minimum tick spacing to 20 pixels. cAxis.syncAxis(Nil) cAxis.setTickDensity(20) If (chartIndex = 1) Then // Speicify a color gradient as a list of colors, and use it in the color axis. Dim colorGradient() As Integer = Array( CType(&h0044cc, Integer), &hffffff, &h00aa00) cAxis.setColorGradient(False, colorGradient) Elseif (chartIndex = 2) Then // Specify the color scale to use in the color axis Dim colorScale() As Double = Array(-1.0, &h1a9850, -0.75, &h66bd63, -0.5, &ha6d96a, -0.25, &hd9ef8b, 0, &hfee08b, 0.25, &hfdae61, 0.5, &hf46d43, 0.75, &hd73027, 1) cAxis.setColorScale(colorScale) Elseif (chartIndex = 3) Then // Specify the color scale to use in the color axis. Also specify an underflow color // &h66ccff (blue) for regions that fall below the lower axis limit. Dim colorScale() As Double = Array(0, &hffff99, 0.2, &h80cdc1, 0.4, &h35978f, 0.6, &h01665e, 0.8, &h003c30, 1) cAxis.setColorScale(colorScale, &h66ccff) End If // Set the center of the plot region at (230, 250), and set width x depth x height to 240 x 240 // x 170 pixels c.setPlotRegion(230, 250, 240, 240, 170) // Set the plot region wall thichness to 3 pixels c.setWallThickness(3) // Set the elevation and rotation angles to 45 degrees c.setViewAngle(45, 45) // Set the perspective level to 20 c.setPerspective(20) // Spline interpolate data to a 50 x 50 grid for a smooth surface c.setInterpolation(50, 50) // Set the axis title Call c.xAxis.setTitle("X-Axis", "Arial Bold", 10) Call c.yAxis.setTitle("Y-Axis", "Arial Bold", 10) Call c.zAxis.setTitle("Z Axis", "Arial Bold", 10) // 2x for higher DPI displays c.setOutputOptions("bmpscale=2") // Output the chart Dim pic As Picture = c.makeChartPicture Dim w As New MainWindow w.pic = pic w.Left = 10 + w.Width * chartIndex w.top = 50 End Sub
End Class
Class MainWindow Inherits Window
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.


💬 Ask a question or report a problem