By Lance Levendowski - Friday, May 6, 2016
Overlapping NChartControls disappear if NChartControl.Settings.RenderSurface = Window when one of the overlapping NChartControls is shown by setting NChartControl.Visible = True and the other overlapping NChartControls are hidden by setting NChartControl.Visible = False.
Is there a way to prevent the NChartControls from disappearing in this situation?
Use the following code and click the “Change Chart” button on the form to reproduce the issue.
Public Class OverlappingChartsWhenRenderToWindowForm Inherits Windows.Forms.Form
Private _ChartControl1 As Nevron.Chart.WinForm.NChartControl Private _ChartControl2 As Nevron.Chart.WinForm.NChartControl Private _ChartControls() As Nevron.Chart.WinForm.NChartControl Private _IndexOfVisibleChartControl As Integer
Private WithEvents _Button1 As Windows.Forms.Button Private WithEvents _CheckBox1 As Windows.Forms.CheckBox
Public Sub New() MyBase.New() Call InitializeControls() End Sub
Private Sub InitializeControls() Me.Size = New Drawing.Size(800, 600) Me.StartPosition = FormStartPosition.CenterScreen
Dim lowResolutionDataSize As New Drawing.Size(20, 20)
Const fillMode As Nevron.Chart.SurfaceFillMode = Nevron.Chart.SurfaceFillMode.Uniform Const renderSurface As Nevron.GraphicsCore.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window Const shadingMode As Nevron.Chart.ShadingMode = Nevron.Chart.ShadingMode.Smooth Const triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode = Nevron.Chart.MeshSurfaceCellTriangulationMode.MaxDiagonal
Dim bounds As Drawing.Rectangle = Me.ClientRectangle Me._ChartControl1 = CreateChartControlWithMeshSurface(Me, "Chart #1", bounds, Color.SlateBlue, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize) Me._ChartControl2 = CreateChartControlWithMeshSurface(Me, "Chart #2", bounds, Color.Coral, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize) Me._ChartControls = {Me._ChartControl1, Me._ChartControl2} Me._IndexOfVisibleChartControl = 0
Me._Button1 = New Windows.Forms.Button Me._Button1.Text = "Change Chart" Me._Button1.Location = New Drawing.Point(0, Me._ChartControl1.Bottom) Me._Button1.Width = 128 Me.Height += (Me._Button1.Height) Me.Controls.Add(Me._Button1)
Me._CheckBox1 = New Windows.Forms.CheckBox Me._CheckBox1.Text = "Render to Window" Me._CheckBox1.Location = New Drawing.Point(Me._Button1.Right + 4, Me._ChartControl1.Bottom) Me._CheckBox1.AutoSize = True Me._CheckBox1.Anchor = AnchorStyles.Left Or AnchorStyles.Bottom Me._CheckBox1.Checked = (renderSurface = Nevron.GraphicsCore.RenderSurface.Window) Me.Controls.Add(Me._CheckBox1)
Call Me.UpdateVisibleChartControl(updateIndex:=False) End Sub
Public Function CreateChartControlWithMeshSurface( _ ByVal parent As Windows.Forms.Control, _ ByVal title As String, _ ByVal bounds As Drawing.Rectangle, _ ByVal color As Drawing.Color, _ ByVal fillMode As Nevron.Chart.SurfaceFillMode, _ ByVal renderSurface As Nevron.GraphicsCore.RenderSurface, _ ByVal shadingMode As Nevron.Chart.ShadingMode, _ ByVal triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode, _ ByVal dataSize As Drawing.Size) As Nevron.Chart.WinForm.NChartControl
Dim chartControl As New Nevron.Chart.WinForm.NChartControl chartControl.Bounds = bounds chartControl.Settings.RenderSurface = renderSurface ' chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NPanelSelectorTool()) chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NTrackballTool())
Dim titleLabel As Nevron.Chart.NLabel = chartControl.Labels.AddHeader(title) titleLabel.TextStyle.FontStyle = New Nevron.GraphicsCore.NFontStyle("Times New Roman", 18, FontStyle.Italic) titleLabel.TextStyle.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(Drawing.Color.FromArgb(64, 64, 255))
Dim chart As Nevron.Chart.NChart = chartControl.Charts(0) chart.Enable3D = True chart.Width = 60.0F chart.Depth = 60.0F chart.Height = 25.0F chart.Projection.SetPredefinedProjection(Nevron.GraphicsCore.PredefinedProjection.PerspectiveTilted) chart.LightModel.SetPredefinedLightModel(Nevron.GraphicsCore.PredefinedLightModel.MetallicLustre)
Dim linearScale As Nevron.Chart.NLinearScaleConfigurator = New Nevron.Chart.NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Back, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(Nevron.Chart.StandardAxis.PrimaryX).ScaleConfigurator = linearScale
linearScale = New Nevron.Chart.NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Left, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(Nevron.Chart.StandardAxis.Depth).ScaleConfigurator = linearScale
Dim surface As Nevron.Chart.NMeshSurfaceSeries = CType(chart.Series.Add(Nevron.Chart.SeriesType.MeshSurface), Nevron.Chart.NMeshSurfaceSeries) surface.Name = "Surface" surface.Legend.Mode = Nevron.Chart.SeriesLegendMode.SeriesLogic surface.FillMode = fillMode surface.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(color) surface.ShadingMode = shadingMode surface.CellTriangulationMode = triangulationMode ' Call SetSurfaceData(surface, dataSize)
parent.Controls.Add(chartControl)
Return chartControl End Function Private Sub SetSurfaceData( _ ByVal surface As Nevron.Chart.NMeshSurfaceSeries, _ ByVal dataSize As Drawing.Size)
Dim x, y, z As Double Dim width As Integer = dataSize.Width Dim height As Integer = dataSize.Height Dim positionScaleFactorX As Double = CDbl(width) / 20.0# Dim positionScaleFactorZ As Double = CDbl(height) / 20.0# Const positionRangeX As Double = 20.0# Const positionRangeZ As Double = 20.0# Const positionStartX As Double = -(0.5# * positionRangeX) Const positionStartZ As Double = -(0.5# * positionRangeZ) Dim deltaX As Double = (positionRangeX / CDbl(width - 1)) Dim deltaZ As Double = (positionRangeZ / CDbl(height - 1)) ' surface.Data.SetGridSize(dataSize.Width, dataSize.Height) ' For j As Integer = 0 To (height - 1) z = CDbl(j) * deltaZ + positionStartZ For i As Integer = 0 To (width - 1) x = CDbl(i) * deltaX + positionStartX
y = Math.Sin(i / (3.0 * positionScaleFactorX)) * Math.Sin(j / (3.0 * positionScaleFactorZ))
If y < 0 Then y = Math.Abs(y / 2.0) End If
surface.Data.SetValue(i, j, y, x, z) Next i Next j End Sub
Private Sub _Button_Click(sender As Object, e As System.EventArgs) Handles _Button1.Click Call Me.UpdateVisibleChartControl(updateIndex:=True) End Sub
Private Sub _CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles _CheckBox1.CheckedChanged Dim uBound As Integer = Me._ChartControls.GetUpperBound(0) For i As Integer = 0 To uBound With Me._ChartControls(i) If (Me._CheckBox1.Checked) Then .Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window Else .Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Bitmap End If End With Next i End Sub
Private Sub UpdateVisibleChartControl(ByVal updateIndex As Boolean) Dim uBound As Integer = Me._ChartControls.GetUpperBound(0) If updateIndex Then If (Me._IndexOfVisibleChartControl = uBound) Then Me._IndexOfVisibleChartControl = 0 Else Me._IndexOfVisibleChartControl += 1 End If End If
'Show the appropriate form. Me._ChartControls(Me._IndexOfVisibleChartControl).Visible = True
'Hide the other forms. For i As Integer = 0 To uBound If (i <> Me._IndexOfVisibleChartControl) Then Me._ChartControls(i).Visible = False End If Next i End Sub
End Class
|
By Nevron Support - Monday, May 9, 2016
Hi Lance, We were not able to reproduce the problem. Please send a small example app to support@nevron.com that reproduces this issue...
|
By Lance Levendowski - Tuesday, May 10, 2016
I emailed a sample application with source code to support@nevron.com as requested.
|
By Lance Levendowski - Wednesday, May 18, 2016
I tested the application that I emailed to Nevron support and this issue seems to be related to the type of video card. Here are my results:
1. GeForce GTX 980M, Windows 10 x64 - Charts disappear when rendering to a window 2. GeForce GTX 760, Windows 10 x64 - Charts disappear when rendering to a window 3. Old Notebook with Radeon Video Card, Windows 10 x64 - Charts do not disappear 4. Desktop using Intel HD Graphics 4000 Windows 7 x64 - Charts do not disappear
Hope this helps. Please let me know if you need any more information.
|
|