Polar Point Example for WPF

Nevron NOV Chart for WPF ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WPF Chart examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Polar Point Example for WPF Description

This example demonstrates how to create a polar point chart.


Polar Point Example

C# Polar Point Example Code for Nevron Chart for WPF
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NPolarPointExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			NChartViewWithCommandBars chartViewWithCommandBars = new NChartViewWithCommandBars();
			NChartView chartView = chartViewWithCommandBars.View;
			chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Polar);

			// configure title
			chartView.Surface.Titles[0].Text = "Polar Point";

			// configure chart
			m_Chart = (NPolarChart)chartView.Surface.Charts[0];

			m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue);

			// setup polar axis
			NLinearScale linearScale = (NLinearScale)m_Chart.Axes[ENPolarAxis.PrimaryValue].Scale;
			linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
			linearScale.InflateViewRangeBegin = true;
			linearScale.InflateViewRangeEnd = true;

			linearScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;

			NScaleStrip strip = new NScaleStrip();
			strip.Fill = new NColorFill(NColor.FromColor(NColor.Beige, 0.4f));
			strip.Interlaced = true;
			linearScale.Strips.Add(strip);
            linearScale.MajorGridLines.Visible = true;

			// setup polar angle axis
			NAngularScale angularScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;
            angularScale.MajorGridLines.Visible = true;

			// create three polar point series
            Random random = new Random();
            NPolarSeries s1 = CreatePolarPointSeries("Sample 1", ENPointShape2D.Ellipse, random);
            NPolarSeries s2 = CreatePolarPointSeries("Sample 2", ENPointShape2D.Rectangle, random);
            NPolarSeries s3 = CreatePolarPointSeries("Sample 3", ENPointShape2D.Triangle, random);

			// add the series to the chart
			m_Chart.Series.Add(s1);
			m_Chart.Series.Add(s2);
			m_Chart.Series.Add(s3);

			chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);

			return group;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create a polar point chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Polar Point Series", "https://www.nevron.com/docs/openvision/polar-point-chart-series.html"), ("Polar Chart", "https://www.nevron.com/docs/openvision/polar-chart.html"), ("Polar Axes", "https://www.nevron.com/docs/openvision/polar-chart-axes.html"), }; } #endregion #region Implementation private NPolarSeries CreatePolarPointSeries(string name, ENPointShape2D shape, Random random) { NPolarPointSeries series = new NPolarPointSeries(); series.Name = name; series.InflateMargins = false; NDataLabelStyle dataLabelStyle = new NDataLabelStyle(); dataLabelStyle.Visible = false; dataLabelStyle.Format = " - "; series.DataLabelStyle = dataLabelStyle; series.Shape = shape; series.Size = 3.0; // add data for (int i = 0; i < 1000; i++) { series.DataPoints.Add(new NPolarPointDataPoint(random.Next(360), random.Next(100))); } return series; } #endregion #region Event Handlers #endregion #region Fields NPolarChart m_Chart; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Polar Point Example for WPF Solution

VB.NET Polar Point Example Code for Nevron Chart for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Imports System

Class MainWindow

#Region "Constructors"

	Public Sub New()
		' This call is required by the designer.
		InitializeComponent()

		' Add any initialization after the InitializeComponent() call.

		' Set form title
		Title = "NOV WPF - NPolarPointExample"

		' Create the NOV example and its controls
		Dim exampleContent As NWidget = CreateExampleContent()
		Dim exampleControls As NWidget = CreateExampleControls()
		If Not exampleControls Is Nothing Then
			exampleControls.PreferredWidth = 300
		End If

		' Place the example and its controls in a pair box
		Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
		pairBox.FillMode = ENStackFillMode.First
		pairBox.FitMode = ENStackFitMode.First
		pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

		' Host the example in the form
		Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
		Content = host
	End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
            Dim chartView = chartViewWithCommandBars.View
            chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Polar)

            ' configure title
            chartView.Surface.Titles(0).Text = "Polar Point"

            ' configure chart
            m_Chart = CType(chartView.Surface.Charts(0), NPolarChart)

            m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue)

            ' setup polar axis
            Dim linearScale As NLinearScale = m_Chart.Axes(ENPolarAxis.PrimaryValue).Scale
            linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick
            linearScale.InflateViewRangeBegin = True
            linearScale.InflateViewRangeEnd = True

            linearScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot

            Dim strip As NScaleStrip = New NScaleStrip()
            strip.Fill = New NColorFill(NColor.FromColor(NColor.Beige, 0.4F))
            strip.Interlaced = True
            linearScale.Strips.Add(strip)
            linearScale.MajorGridLines.Visible = True

            ' setup polar angle axis
            Dim angularScale As NAngularScale = m_Chart.Axes(ENPolarAxis.PrimaryAngle).Scale
            angularScale.MajorGridLines.Visible = True

            ' create three polar point series
            Dim random As Random = New Random()
            Dim s1 = CreatePolarPointSeries("Sample 1", ENPointShape2D.Ellipse, random)
            Dim s2 = CreatePolarPointSeries("Sample 2", ENPointShape2D.Rectangle, random)
            Dim s3 = CreatePolarPointSeries("Sample 3", ENPointShape2D.Triangle, random)

            ' add the series to the chart
            m_Chart.Series.Add(s1)
            m_Chart.Series.Add(s2)
            m_Chart.Series.Add(s3)

            chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series))

            Return chartViewWithCommandBars
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)

            Return group
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to create a polar point chart.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Polar Point Series", "https://www.nevron.com/docs/openvision/polar-point-chart-series.html"), ("Polar Chart", "https://www.nevron.com/docs/openvision/polar-chart.html"), ("Polar Axes", "https://www.nevron.com/docs/openvision/polar-chart-axes.html")} End Function #End Region #Region "Implementation" Private Function CreatePolarPointSeries(name As String, shape As ENPointShape2D, random As Random) As NPolarSeries Dim series As NPolarPointSeries = New NPolarPointSeries() series.Name = name series.InflateMargins = False Dim dataLabelStyle As NDataLabelStyle = New NDataLabelStyle() dataLabelStyle.Visible = False dataLabelStyle.Format = " - " series.DataLabelStyle = dataLabelStyle series.Shape = shape series.Size = 3.0 ' add data For i = 0 To 999 series.DataPoints.Add(New NPolarPointDataPoint(random.Next(360), random.Next(100))) Next Return series End Function #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_Chart As NPolarChart #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Polar Point Example for WPF Solution

Related Documentation Links