Home Forums WinForms controls Xceed Chart for WinForms Polar chart has unequal angles

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19103 |

    Hi, I have a very straightforward polar chart, with the standard 30 degrees between radial marker lines.  It is all working fine, but I notice that the angles between the radial marker lines are not equal.  The angles closer to vertical are smaller than those closer to horizontal.  It is quite noticeable – the difference between the biggest and smallest angles is almost 2 to 1.  I am using Stretch margin mode on the chart, and thought that might be causing it.  But I have tried tweaking it and cannot fix the problem.  Any ideas?  The examples in the Chart Explorer do not exhibit this problem.  I’m quite perplexed by this.  My chart software is version 4.0.6353.0 (on the dll).

     

    Imported from legacy forums. Posted by Steve (had 2999 views)

    User (Old forums)
    Member
    Post count: 23064

    Do you have a code snippet showing how you set up your chart, so we can try to reproduce on our side?

    You can also try to upgrade to our latest version to see if it solves the issue (I’ll be testing with the latest version).

    Imported from legacy forums. Posted by André (had 424 views)

    User (Old forums)
    Member
    Post count: 23064

    Here is the code for the form and my code for handling what it does.  The polar series is predefined, and I simply fill it with values each time I need it.  But the unequal angles appear even in design view, so it is nothing to do with how it is being used.

     frmMainPolar.Designer.v ——————————————————————-

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class frmMainPolar
        Inherits System.Windows.Forms.Form

        ‘Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        ‘Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        ‘NOTE: The following procedure is required by the Windows Form Designer
        ‘It can be modified using the Windows Form Designer. 
        ‘Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMainPolar))
            Me.grphPolar = New Xceed.Chart.ChartControl
            Me.txtFrequency = New System.Windows.Forms.TextBox
            Me.Label1 = New System.Windows.Forms.Label
            Me.cmdStart = New System.Windows.Forms.Button
            Me.cmdClose = New System.Windows.Forms.Button
            Me.cmbFreqUnits = New System.Windows.Forms.ComboBox
            Me.cmbSpanUnits = New System.Windows.Forms.ComboBox
            Me.Label2 = New System.Windows.Forms.Label
            Me.txtSpan = New System.Windows.Forms.TextBox
            Me.cmdSaveGraph = New System.Windows.Forms.Button
            Me.numSweepTime = New System.Windows.Forms.NumericUpDown
            Me.Label3 = New System.Windows.Forms.Label
            Me.Label4 = New System.Windows.Forms.Label
            Me.txtAntennaHeight = New System.Windows.Forms.TextBox
            Me.Label5 = New System.Windows.Forms.Label
            CType(Me.numSweepTime, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            ‘
            ‘grphPolar
            ‘
            Me.grphPolar.BackColor = System.Drawing.SystemColors.Control
            Me.grphPolar.Background = CType(resources.GetObject(“grphPolar.Background”), Xceed.Chart.Standard.Background)
            Me.grphPolar.Charts = CType(resources.GetObject(“grphPolar.Charts”), Xceed.Chart.Core.ChartCollection)
            Me.grphPolar.InteractivityOperations = CType(resources.GetObject(“grphPolar.InteractivityOperations”), Xceed.Chart.Core.InteractivityOperationsCollection)
            Me.grphPolar.Labels = CType(resources.GetObject(“grphPolar.Labels”), Xceed.Chart.Standard.ChartLabelCollection)
            Me.grphPolar.Legends = CType(resources.GetObject(“grphPolar.Legends”), Xceed.Chart.Core.LegendCollection)
            Me.grphPolar.Location = New System.Drawing.Point(10, 13)
            Me.grphPolar.Margin = New System.Windows.Forms.Padding(5)
            Me.grphPolar.Name = “grphPolar”
            Me.grphPolar.Settings = CType(resources.GetObject(“grphPolar.Settings”), Xceed.Chart.Core.Settings)
            Me.grphPolar.Size = New System.Drawing.Size(700, 600)
            Me.grphPolar.TabIndex = 0
            Me.grphPolar.Text = “grphPolar”
            Me.grphPolar.Watermarks = CType(resources.GetObject(“grphPolar.Watermarks”), Xceed.Chart.Standard.WatermarkCollection)
            ‘
            ‘txtFrequency
            ‘
            Me.txtFrequency.Location = New System.Drawing.Point(822, 18)
            Me.txtFrequency.Margin = New System.Windows.Forms.Padding(5)
            Me.txtFrequency.Name = “txtFrequency”
            Me.txtFrequency.Size = New System.Drawing.Size(101, 26)
            Me.txtFrequency.TabIndex = 1
            Me.txtFrequency.Text = “2450”
            Me.txtFrequency.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
            ‘
            ‘Label1
            ‘
            Me.Label1.AutoSize = True
            Me.Label1.Location = New System.Drawing.Point(721, 21)
            Me.Label1.Name = “Label1”
            Me.Label1.Size = New System.Drawing.Size(93, 20)
            Me.Label1.TabIndex = 2
            Me.Label1.Text = “Frequency”
            ‘
            ‘cmdStart
            ‘
            Me.cmdStart.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.cmdStart.ForeColor = System.Drawing.Color.Green
            Me.cmdStart.Location = New System.Drawing.Point(844, 239)
            Me.cmdStart.Name = “cmdStart”
            Me.cmdStart.Size = New System.Drawing.Size(160, 116)
            Me.cmdStart.TabIndex = 4
            Me.cmdStart.Text = “Start”
            Me.cmdStart.UseVisualStyleBackColor = True
            ‘
            ‘cmdClose
            ‘
            Me.cmdClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.cmdClose.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.cmdClose.ForeColor = System.Drawing.Color.Red
            Me.cmdClose.Location = New System.Drawing.Point(844, 659)
            Me.cmdClose.Name = “cmdClose”
            Me.cmdClose.Size = New System.Drawing.Size(160, 63)
            Me.cmdClose.TabIndex = 5
            Me.cmdClose.Text = “CLOSE”
            Me.cmdClose.UseVisualStyleBackColor = True
            ‘
            ‘cmbFreqUnits
            ‘
            Me.cmbFreqUnits.Items.AddRange(New Object() {“Hz”, “KHz”, “MHz”})
            Me.cmbFreqUnits.Location = New System.Drawing.Point(926, 18)
            Me.cmbFreqUnits.Name = “cmbFreqUnits”
            Me.cmbFreqUnits.Size = New System.Drawing.Size(72, 28)
            Me.cmbFreqUnits.TabIndex = 54
            Me.cmbFreqUnits.Text = “MHz”
            ‘
            ‘cmbSpanUnits
            ‘
            Me.cmbSpanUnits.Items.AddRange(New Object() {“Hz”, “KHz”, “MHz”})
            Me.cmbSpanUnits.Location = New System.Drawing.Point(926, 54)
            Me.cmbSpanUnits.Name = “cmbSpanUnits”
            Me.cmbSpanUnits.Size = New System.Drawing.Size(72, 28)
            Me.cmbSpanUnits.TabIndex = 57
            Me.cmbSpanUnits.Text = “KHz”
            ‘
            ‘Label2
            ‘
            Me.Label2.AutoSize = True
            Me.Label2.Location = New System.Drawing.Point(721, 57)
            Me.Label2.Name = “Label2”
            Me.Label2.Size = New System.Drawing.Size(51, 20)
            Me.Label2.TabIndex = 56
            Me.Label2.Text = “Span”
            ‘
            ‘txtSpan
            ‘
            Me.txtSpan.Location = New System.Drawing.Point(822, 54)
            Me.txtSpan.Margin = New System.Windows.Forms.Padding(5)
            Me.txtSpan.Name = “txtSpan”
            Me.txtSpan.Size = New System.Drawing.Size(101, 26)
            Me.txtSpan.TabIndex = 55
            Me.txtSpan.Text = “500”
            Me.txtSpan.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
            ‘
            ‘cmdSaveGraph
            ‘
            Me.cmdSaveGraph.ForeColor = System.Drawing.Color.Green
            Me.cmdSaveGraph.Location = New System.Drawing.Point(564, 621)
            Me.cmdSaveGraph.Name = “cmdSaveGraph”
            Me.cmdSaveGraph.Size = New System.Drawing.Size(146, 49)
            Me.cmdSaveGraph.TabIndex = 58
            Me.cmdSaveGraph.Text = “Save Graph”
            Me.cmdSaveGraph.UseVisualStyleBackColor = True
            ‘
            ‘numSweepTime
            ‘
            Me.numSweepTime.Location = New System.Drawing.Point(822, 89)
            Me.numSweepTime.Maximum = New Decimal(New Integer() {5000, 0, 0, 0})
            Me.numSweepTime.Minimum = New Decimal(New Integer() {20, 0, 0, 0})
            Me.numSweepTime.Name = “numSweepTime”
            Me.numSweepTime.Size = New System.Drawing.Size(101, 26)
            Me.numSweepTime.TabIndex = 59
            Me.numSweepTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
            Me.numSweepTime.Value = New Decimal(New Integer() {20, 0, 0, 0})
            ‘
            ‘Label3
            ‘
            Me.Label3.AutoSize = True
            Me.Label3.Location = New System.Drawing.Point(721, 91)
            Me.Label3.Name = “Label3”
            Me.Label3.Size = New System.Drawing.Size(97, 20)
            Me.Label3.TabIndex = 60
            Me.Label3.Text = “Sweeptime”
            ‘
            ‘Label4
            ‘
            Me.Label4.AutoSize = True
            Me.Label4.Location = New System.Drawing.Point(923, 91)
            Me.Label4.Name = “Label4”
            Me.Label4.Size = New System.Drawing.Size(32, 20)
            Me.Label4.TabIndex = 61
            Me.Label4.Text = “ms”
            ‘
            ‘txtAntennaHeight
            ‘
            Me.txtAntennaHeight.Location = New System.Drawing.Point(822, 122)
            Me.txtAntennaHeight.Name = “txtAntennaHeight”
            Me.txtAntennaHeight.Size = New System.Drawing.Size(100, 26)
            Me.txtAntennaHeight.TabIndex = 62
            ‘
            ‘Label5
            ‘
            Me.Label5.Location = New System.Drawing.Point(721, 116)
            Me.Label5.Name = “Label5”
            Me.Label5.Size = New System.Drawing.Size(78, 41)
            Me.Label5.TabIndex = 63
            Me.Label5.Text = “Antenna Height”
            ‘
            ‘frmMainPolar
            ‘
            Me.AutoScaleDimensions = New System.Drawing.SizeF(10.0!, 20.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(1016, 734)
            Me.Controls.Add(Me.Label5)
            Me.Controls.Add(Me.txtAntennaHeight)
            Me.Controls.Add(Me.Label4)
            Me.Controls.Add(Me.Label3)
            Me.Controls.Add(Me.numSweepTime)
            Me.Controls.Add(Me.cmdSaveGraph)
            Me.Controls.Add(Me.cmbSpanUnits)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.txtSpan)
            Me.Controls.Add(Me.cmbFreqUnits)
            Me.Controls.Add(Me.cmdClose)
            Me.Controls.Add(Me.cmdStart)
            Me.Controls.Add(Me.Label1)
            Me.Controls.Add(Me.txtFrequency)
            Me.Controls.Add(Me.grphPolar)
            Me.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.Margin = New System.Windows.Forms.Padding(5)
            Me.Name = “frmMainPolar”
            Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
            Me.Text = “Polar Capture and Plot”
            CType(Me.numSweepTime, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
            Me.PerformLayout()

        End Sub
        Friend WithEvents grphPolar As Xceed.Chart.ChartControl
        Friend WithEvents txtFrequency As System.Windows.Forms.TextBox
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents cmdStart As System.Windows.Forms.Button
        Friend WithEvents cmdClose As System.Windows.Forms.Button
        Friend WithEvents cmbFreqUnits As System.Windows.Forms.ComboBox
        Friend WithEvents cmbSpanUnits As System.Windows.Forms.ComboBox
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents txtSpan As System.Windows.Forms.TextBox
        Friend WithEvents cmdSaveGraph As System.Windows.Forms.Button
        Friend WithEvents numSweepTime As System.Windows.Forms.NumericUpDown
        Friend WithEvents Label3 As System.Windows.Forms.Label
        Friend WithEvents Label4 As System.Windows.Forms.Label
        Friend WithEvents txtAntennaHeight As System.Windows.Forms.TextBox
        Friend WithEvents Label5 As System.Windows.Forms.Label
    End Class

     

    frmmainPolar.vb———————————————————————————

     Imports Xceed.Chart.Core
    Imports Xceed.Chart.GraphicsCore
    Imports System.threading

    Public Class frmMainPolar

        Private Const iReadInterval As Integer = 500     ‘ no of milliseconds between readings
        Dim bStopSweep As Boolean

        Private Sub txtFrequency_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFrequency.Click

            Dim f As frmKeypad

            If gTouchScreen Then
                f = New frmKeypad
                f.sEntryType = “Frequency”
                f.txtUnit.Text = cmbFreqUnits.Text
                If f.ShowDialog = Windows.Forms.DialogResult.OK Then
                    txtFrequency.Text = f.txtNumber.Text
                    cmbFreqUnits.Text = f.txtUnit.Text
                End If
            End If

        End Sub

        Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click

            Dim iFreq As Double, iSpan As Double, iAngle As Single, iStep As Single, iAmplitude As Single
            Dim ps As PolarSeries
            Dim i As Integer

            If cmdStart.Text = “Stop” Then
                bStopSweep = True
                Exit Sub
            End If

            iFreq = Val(txtFrequency.Text)
            If cmbFreqUnits.Text = “KHz” Then iFreq *= 1000
            If cmbFreqUnits.Text = “MHz” Then iFreq *= 1000000
            iSpan = Val(txtSpan.Text)
            If cmbSpanUnits.Text = “KHz” Then iSpan *= 1000
            If cmbSpanUnits.Text = “MHz” Then iSpan *= 1000000

            gMyAnalyser.SweepSingle()
            gMyAnalyser.CentreFrequency = Val(iFreq)
            gMyAnalyser.Span = iSpan
            gMyAnalyser.SweepTime = numSweepTime.Value
            gMyAnalyser.MarkerOn()
            gMyAnalyser.MarkerNormal()
            gMyAnalyser.TakeSweep()
            gMyAnalyser.MarkerToHighestPeak()
            gMyAnalyser.TakeSweep()
            gMyAnalyser.MarkerToCentreFrequency()
            gMyAnalyser.TakeSweep()
            gMyAnalyser.MarkerToHighestPeak()
            gMyAnalyser.SweepContinuous()

            If MsgBox(“Analyser is ready: click OK when ready to start sweep, or Cancel to stop now.”, MsgBoxStyle.OkCancel + MsgBoxStyle.Information, “EMC Lab”) = MsgBoxResult.Cancel Then Exit Sub

            ps = grphPolar.Charts(0).Series(0)  ‘ get the polar series
            ps.Values.Clear()
            ps.Angles.Clear()
            bStopSweep = False

            cmdStart.Text = “Stop”

            Do
                iAmplitude = gMyAnalyser.GetMarkerAmplitude()
                ps.AddPolar(iAmplitude, 0)
                Application.DoEvents()
            Loop Until bStopSweep

            Beep()
            MsgBox(“Sweep Complete: ” & ps.Values.Count & ” readings taken”, MsgBoxStyle.Information, “EMCLab”)
            cmdStart.Text = “Start”
            cmdSaveGraph.ForeColor = Color.Red

            ‘ Distribute the readings around the 360 degrees of the graph
            iStep = 360 / ps.Values.Count
            iAngle = 0
            For i = 0 To ps.Values.Count – 1
                ps.Angles(i) = iAngle
                iAngle += iStep
            Next
            grphPolar.Refresh()

        End Sub

        Private Sub frmMainPolar_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

            If cmdSaveGraph.ForeColor = Color.Red Then
                If MsgBox(“Graph is not saved: do you want to save it before closing?”, MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton1, “EMCLab”) = MsgBoxResult.Yes Then cmdSaveGraph_Click(cmdSaveGraph, e)
            End If

        End Sub

        Private Sub frmMainPolar_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Dim f As frmSelectInstrument

            If gMyAnalyser Is Nothing Then
                f = New frmSelectInstrument
                f.sClass = “CR”
                If f.ShowDialog = Windows.Forms.DialogResult.Cancel Then
                    Close()
                    Exit Sub
                End If
            End If

            If Not gFlashDrivePresent Then cmdSaveGraph.Enabled = False

        End Sub

        Private Sub txtSpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSpan.Click

            Dim f As frmKeypad

            If gTouchScreen Then
                f = New frmKeypad
                f.sEntryType = “Frequency”
                f.txtUnit.Text = cmbSpanUnits.Text
                If f.ShowDialog = Windows.Forms.DialogResult.OK Then
                    txtSpan.Text = f.txtNumber.Text
                    cmbSpanUnits.Text = f.txtUnit.Text
                End If
            End If

        End Sub

        Private Sub cmdSaveGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveGraph.Click

            Dim f As New frmSaveImage

            f.CategoryChanged(f.optOther, e)
            If f.ShowDialog() = Windows.Forms.DialogResult.OK Then
                SaveImageWithAnnotation(grphPolar, f, False)
                If gFlashDrivePresent Then myJob.IncrementGraphNumber()
                cmdSaveGraph.ForeColor = Color.Green
            End If

        End Sub

    End Class

    Imported from legacy forums. Posted by Steve (had 2179 views)

    User (Old forums)
    Member
    Post count: 23064

    You must make sure the chart itself is a perfect square, so that polar series draws as a perfect circle.  If not, the circle will be skewed, as an ellipse.  To accomplish that, you need to set the width and height of the chart to the same value.

    e.g.:

      Dim chart As Chart = grphPolar.Charts(0)
      chart.Width = 70.0f;
      chart.Height = 70.0f;

     

    Imported from legacy forums. Posted by André (had 369 views)

    User (Old forums)
    Member
    Post count: 23064

    Many thanks Andre – so obvious when you know!  I tried to size it using the MarginMode and margins, but clearly ended up with skewed sizing in the X and Y directions.  Didn’t notice that.  I do find the sizing of charts unnecessarily confusing – but that’s another story.  Anyway, this problem solved, thanks again.

    Imported from legacy forums. Posted by Steve (had 3378 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.