Sub NPlotSurface(ByVal Data As ArrayList, ByVal FreqPoints As Integer, ByVal AnglePoints As Integer, ByVal Flat As Boolean, ByVal TitleText As String, ByVal NChart1 As NChartControl) If Not IsNothing(Data) AndAlso Data.Count > 0 Then NChart1.Clear() ' set the initial chart title Dim title As NLabel = NChart1.Labels.AddHeader(TitleText) title.TextStyle.FontStyle = New NFontStyle("Century Gothic", 15, FontStyle.Regular) ' setup chart Dim chart As NChart = NChart1.Charts(0) If Not Flat Then NChart1.Controller.Tools.Add(New NSelectorTool()) NChart1.Controller.Tools.Add(New NTrackballTool()) End If NChart1.BackgroundStyle.FrameStyle.Visible = False chart.Wall(ChartWallType.Back).BorderStyle.Width = New NLength(0) chart.Enable3D = True If Flat Then chart.Height = 0.1F chart.Width = 75.0F chart.Depth = 75.0F chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop) ' chart.LightModel.EnableLighting = False Else chart.Height = 45.0F chart.Width = 60.0F chart.Depth = 60.0F chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted) 'chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft) 'chart.LightModel.EnableLighting = True End If ' setup axes Dim linearScale As NLinearScaleConfigurator = New NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale linearScale.Title.Text = "Angle Degrees" Dim scaleConfiguratorY As NStandardScaleConfigurator = CType(chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NStandardScaleConfigurator) scaleConfiguratorY.Title.Text = "Gain (" & dBunits & ")" Dim scaleConfiguratorZ As NStandardScaleConfigurator = CType(chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator, NStandardScaleConfigurator) scaleConfiguratorZ.Title.Text = "Frequency (MHz)" linearScale = New NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale ' setup surface series Dim surface As NMeshSurfaceSeries = CType(chart.Series.Add(SeriesType.MeshSurface), NMeshSurfaceSeries) surface.Name = "Surface" surface.Legend.Mode = SeriesLegendMode.SeriesLogic surface.FrameMode = SurfaceFrameMode.Contour surface.FillMode = SurfaceFillMode.Zone 'surface.FillStyle = New NColorFillStyle(Color.YellowGreen) 'surface.ShadingMode = ShadingMode.Flat If Flat Then surface.DrawFlat = True Else surface.DrawFlat = False End If surface.PositionValue = 0.5 surface.Data.SetGridSize(AnglePoints, FreqPoints) Dim AngleCounter = 0 Dim FreqCounter = 0 Dim MaxAmp = -900.0 Dim MinAmp = 900.0 For Each dp In Data MaxAmp = Max(MaxAmp, dp.Ampl) MinAmp = Min(MinAmp, dp.Ampl) surface.Data.SetValue(AngleCounter, FreqCounter, dp.ampl, dp.angle, dp.freq / 1000000) FreqCounter += 1 If FreqCounter = FreqPoints Then FreqCounter = 0 AngleCounter += 1 End If Next ' setup a custom palette surface.SyncPaletteWithAxisScale = False surface.SmoothPalette = False surface.AutomaticPalette = False surface.Palette.Clear() ' automatic legend 'surface.Legend.Format = " to " 'surface.ValueFormatter.FormatSpecifier = "0.0" ' legend Dim Colors = {Color.Red, Color.Red, Color.Orange, Color.Yellow, Color.LightGreen, Color.LimeGreen, Color.CornflowerBlue, Color.MediumSlateBlue, Color.Purple} Dim PaletteSteps As Double() ' array of doubles Dim PaletteCount As Integer = 8 Dim LegendItems As NLegendItemCellData() Dim i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15 As New NLegendItemCellData LegendItems = {i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15} Dim legendsCollection As NLegendCollection = NChart1.Legends Dim legend As NLegend = CType(legendsCollection(0), NLegend) legend.Margins = New NMarginsL(10, 10, 10, 10) legend.Dock = DockStyle.Right legend.Mode = LegendMode.Manual legend.ShadowStyle.Type = ShadowType.Solid 'legend.OuterLeftBorderStyle.Width = New NLength(0) 'legend.OuterTopBorderStyle.Width = New NLength(0) 'legend.OuterRightBorderStyle.Width = New NLength(0) 'legend.OuterBottomBorderStyle.Width = New NLength(0) legend.HorizontalBorderStyle.Width = New NLength(0) legend.VerticalBorderStyle.Width = New NLength(0) legend.Data.ExpandMode = LegendExpandMode.ColsFixed legend.Data.ColCount = 2 If MaxAmp - MinAmp > 20 Then PaletteSteps = {0, 1, 2, 3, 6, 9, 12, 15, MaxAmp - MinAmp} ElseIf MaxAmp - MinAmp > 10 Then PaletteSteps = {0, 1, 2, 3, 4, 5, 6, 7, MaxAmp - MinAmp} ElseIf MaxAmp - MinAmp > 4 Then PaletteSteps = {0, 0.5, 1, 1.5, 2, 2.5, 3, 4, MaxAmp - MinAmp} Else PaletteSteps = {0, 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, MaxAmp - MinAmp} End If For i = 0 To PaletteCount surface.Palette.Add(MaxAmp - PaletteSteps(i), Colors(i)) If i <> 0 Then LegendItems((i - 1) * 2) = New NLegendItemCellData LegendItems((i - 1) * 2).MarkShape = LegendMarkShape.None LegendItems((i - 1) * 2).MarkLineStyle.Width = New NLength(3, NGraphicsUnit.Pixel) LegendItems((i - 1) * 2).MarkLineStyle.Color = Colors(i) legend.Data.Items.Add(LegendItems((i - 1) * 2)) LegendItems((i - 1) * 2 + 1).Text = Round(MaxAmp - PaletteSteps(i - 1), 2) & " to " & Round(MaxAmp - PaletteSteps(i), 2) LegendItems((i - 1) * 2 + 1).MarkShape = LegendMarkShape.None LegendItems((i - 1) * 2 + 1).MarkLineStyle.Width = New NLength(0, NGraphicsUnit.Pixel) legend.Data.Items.Add(LegendItems((i - 1) * 2 + 1)) End If Next ' configure horizontal interlacing Dim m_RowInterlaceStyle As New NLegendInterlaceStyle m_RowInterlaceStyle.Begin = 1 m_RowInterlaceStyle.Length = 1 m_RowInterlaceStyle.Interval = 1 m_RowInterlaceStyle.FillStyle = New NColorFillStyle(Color.FromArgb(125, Color.LightGray)) legend.InterlaceStyles.Add(m_RowInterlaceStyle) NChart1.Refresh() End If End Sub