Overlapping ChartControls Disappear when Render to Window


Author
Message
Lance Levendowski
Lance Levendowski
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 60, Visits: 157
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

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search