Radar Line 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.

Radar Line Example for WPF Description

This example demonstrates how to create a radar line chart.


Radar Line Example

C# Radar Line 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 - NRadarLineExample";

			// 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.Radar);

			// configure title
			chartView.Surface.Titles[0].Text = "Radar Line";

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

			// set some axis labels
			AddAxis("Vitamin A");
			AddAxis("Vitamin B1");
			AddAxis("Vitamin B2");
			AddAxis("Vitamin B6");
			AddAxis("Vitamin B12");
			AddAxis("Vitamin C");
			AddAxis("Vitamin D");
			AddAxis("Vitamin E");

			NLinearScale radarScale = (NLinearScale)m_Chart.Axes[0].Scale;
			radarScale.MajorGridLines.Visible = true;

			NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);
			strip.Interlaced = true;
			radarScale.Strips.Add(strip);

			m_RadarLine1 = new NRadarLineSeries();
			m_Chart.Series.Add(m_RadarLine1);
			m_RadarLine1.Stroke = new NStroke(2, NChartPalette.BrightPalette[0]);
			m_RadarLine1.Name = "Series 1";
			m_RadarLine1.DataLabelStyle = new NDataLabelStyle(false);
			NMarkerStyle markerStyle1 = new NMarkerStyle();
			markerStyle1.Visible = true;
			markerStyle1.Shape = ENPointShape3D.Ellipse;
			markerStyle1.Size = new NSize(10, 10);
			m_RadarLine1.MarkerStyle = markerStyle1;

			m_RadarLine2 = new NRadarLineSeries();
			m_Chart.Series.Add(m_RadarLine2);
			m_RadarLine2.Stroke = new NStroke(2, NChartPalette.BrightPalette[1]);
			m_RadarLine2.Name = "Series 2";
			m_RadarLine2.DataLabelStyle = new NDataLabelStyle(false);
			NMarkerStyle markerStyle2 = new NMarkerStyle();
			markerStyle2.Visible = true;
			markerStyle2.Shape = ENPointShape3D.Ellipse;
			markerStyle2.Size = new NSize(10, 10);
			m_RadarLine2.MarkerStyle = markerStyle2;

			// fill random data
			Random random = new Random();

			for (int i = 0; i < 8; i++)
			{
				m_RadarLine1.DataPoints.Add(new NRadarLineDataPoint(random.Next(50, 90)));
				m_RadarLine2.DataPoints.Add(new NRadarLineDataPoint(random.Next(0, 100)));
			}
			
			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			NNumericUpDown beginAngleUpDown = new NNumericUpDown();
			beginAngleUpDown.ValueChanged +=OnBeginAngleUpDownValueChanged;
			beginAngleUpDown.Value = 90;
			stack.Add(NPairBox.Create("Begin Angle:", beginAngleUpDown));

			NComboBox titleAngleModeComboBox = new NComboBox();
			titleAngleModeComboBox.Items.FillFromEnum();
			titleAngleModeComboBox.SelectedIndexChanged +=OnTitleAngleModeComboBoxSelectedIndexChanged;
			titleAngleModeComboBox.SelectedIndex = (int)ENScaleLabelAngleMode.Scale;
			stack.Add(NPairBox.Create("Title Angle Mode:", titleAngleModeComboBox));

			NNumericUpDown titleAngleUpDown = new NNumericUpDown();
			titleAngleUpDown.ValueChanged += OnTitleAngleUpDownValueChanged;
			titleAngleUpDown.Value = 0;
			stack.Add(NPairBox.Create("Title Angle:", titleAngleUpDown));

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

This example demonstrates how to create a radar line chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Radar Line Series", "https://www.nevron.com/docs/openvision/radar-line-chart-series.html"), ("Radar Chart", "https://www.nevron.com/docs/openvision/radar-chart.html"), ("Radar Axes", "https://www.nevron.com/docs/openvision/radar-chart-axes.html"), }; } #endregion #region Implementation private void AddAxis(string title) { NRadarAxis axis = new NRadarAxis(); // set title axis.Title = title; axis.TitleAngle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0); // axis.TitleTextStyle.TextFormat = TextFormat.XML; // setup scale NLinearScale linearScale = (NLinearScale)axis.Scale; if (m_Chart.Axes.Count == 0) { // if the first axis then configure grid style and stripes linearScale.MajorGridLines.Stroke = new NStroke(1, NColor.Gainsboro, ENDashStyle.Dot); // add interlaced stripe NScaleStrip strip = new NScaleStrip(); strip.Fill = new NColorFill(NColor.FromRGBA(200, 200, 200, 64)); strip.Interlaced = true; linearScale.Strips.Add(strip); } else { // hide labels linearScale.Labels.Visible = false; } m_Chart.Axes.Add(axis); } #endregion #region Event Handlers void OnBeginAngleUpDownValueChanged(NValueChangeEventArgs arg) { m_Chart.BeginAngle = new NAngle(((NNumericUpDown)arg.TargetNode).Value, NUnit.Degree); } void OnTitleAngleModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { for (int i = 0; i < m_Chart.Axes.Count; i++) { NScaleLabelAngle oldTitleAngle = m_Chart.Axes[i].TitleAngle; m_Chart.Axes[i].TitleAngle = new NScaleLabelAngle((ENScaleLabelAngleMode)((NComboBox)arg.TargetNode).SelectedIndex, oldTitleAngle.CustomAngle); } } void OnTitleAngleUpDownValueChanged(NValueChangeEventArgs arg) { for (int i = 0; i < m_Chart.Axes.Count; i++) { NScaleLabelAngle oldTitleAngle = m_Chart.Axes[i].TitleAngle; m_Chart.Axes[i].TitleAngle = new NScaleLabelAngle(oldTitleAngle.LabelAngleMode, ((NNumericUpDown)arg.TargetNode).Value); } } #endregion #region Fields NRadarChart m_Chart; NRadarLineSeries m_RadarLine1; NRadarLineSeries m_RadarLine2; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Radar Line Example for WPF Solution

VB.NET Radar Line 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 - NRadarLineExample"

		' 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.Radar)

            ' configure title
            chartView.Surface.Titles(0).Text = "Radar Line"

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

            ' set some axis labels
            AddAxis("Vitamin A")
            AddAxis("Vitamin B1")
            AddAxis("Vitamin B2")
            AddAxis("Vitamin B6")
            AddAxis("Vitamin B12")
            AddAxis("Vitamin C")
            AddAxis("Vitamin D")
            AddAxis("Vitamin E")

            Dim radarScale = CType(m_Chart.Axes(0).Scale, NLinearScale)
            radarScale.MajorGridLines.Visible = True

            Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(ENNamedColor.Beige), Nothing, True, 0, 0, 1, 1)
            strip.Interlaced = True
            radarScale.Strips.Add(strip)

            m_RadarLine1 = New NRadarLineSeries()
            m_Chart.Series.Add(m_RadarLine1)
            m_RadarLine1.Stroke = New NStroke(2, NChartPalette.BrightPalette(0))
            m_RadarLine1.Name = "Series 1"
            m_RadarLine1.DataLabelStyle = New NDataLabelStyle(False)
            Dim markerStyle1 As NMarkerStyle = New NMarkerStyle()
            markerStyle1.Visible = True
            markerStyle1.Shape = ENPointShape3D.Ellipse
            markerStyle1.Size = New NSize(10, 10)
            m_RadarLine1.MarkerStyle = markerStyle1

            m_RadarLine2 = New NRadarLineSeries()
            m_Chart.Series.Add(m_RadarLine2)
            m_RadarLine2.Stroke = New NStroke(2, NChartPalette.BrightPalette(1))
            m_RadarLine2.Name = "Series 2"
            m_RadarLine2.DataLabelStyle = New NDataLabelStyle(False)
            Dim markerStyle2 As NMarkerStyle = New NMarkerStyle()
            markerStyle2.Visible = True
            markerStyle2.Shape = ENPointShape3D.Ellipse
            markerStyle2.Size = New NSize(10, 10)
            m_RadarLine2.MarkerStyle = markerStyle2

            ' fill random data
            Dim random As Random = New Random()

            For i = 0 To 7
                m_RadarLine1.DataPoints.Add(New NRadarLineDataPoint(random.Next(50, 90)))
                m_RadarLine2.DataPoints.Add(New NRadarLineDataPoint(random.Next(0, 100)))
            Next

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

            Dim beginAngleUpDown As NNumericUpDown = New NNumericUpDown()
            beginAngleUpDown.ValueChanged += AddressOf OnBeginAngleUpDownValueChanged
            beginAngleUpDown.Value = 90
            stack.Add(NPairBox.Create("Begin Angle:", beginAngleUpDown))

            Dim titleAngleModeComboBox As NComboBox = New NComboBox()
            titleAngleModeComboBox.Items.FillFromEnum(Of ENScaleLabelAngleMode)()
            titleAngleModeComboBox.SelectedIndexChanged += AddressOf OnTitleAngleModeComboBoxSelectedIndexChanged
            titleAngleModeComboBox.SelectedIndex = CInt(ENScaleLabelAngleMode.Scale)
            stack.Add(NPairBox.Create("Title Angle Mode:", titleAngleModeComboBox))

            Dim titleAngleUpDown As NNumericUpDown = New NNumericUpDown()
            titleAngleUpDown.ValueChanged += AddressOf OnTitleAngleUpDownValueChanged
            titleAngleUpDown.Value = 0
            stack.Add(NPairBox.Create("Title Angle:", titleAngleUpDown))

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

This example demonstrates how to create a radar line chart.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Radar Line Series", "https://www.nevron.com/docs/openvision/radar-line-chart-series.html"), ("Radar Chart", "https://www.nevron.com/docs/openvision/radar-chart.html"), ("Radar Axes", "https://www.nevron.com/docs/openvision/radar-chart-axes.html")} End Function #End Region #Region "Implementation" Private Sub AddAxis(title As String) Dim axis As NRadarAxis = New NRadarAxis() ' set title axis.Title = title axis.TitleAngle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0) ' axis.TitleTextStyle.TextFormat = TextFormat.XML; ' setup scale Dim linearScale = CType(axis.Scale, NLinearScale) If m_Chart.Axes.Count = 0 Then ' if the first axis then configure grid style and stripes linearScale.MajorGridLines.Stroke = New NStroke(1, NColor.Gainsboro, ENDashStyle.Dot) ' add interlaced stripe Dim strip As NScaleStrip = New NScaleStrip() strip.Fill = New NColorFill(NColor.FromRGBA(200, 200, 200, 64)) strip.Interlaced = True linearScale.Strips.Add(strip) Else ' hide labels linearScale.Labels.Visible = False End If m_Chart.Axes.Add(axis) End Sub #End Region #Region "Event Handlers" Private Sub OnBeginAngleUpDownValueChanged(arg As NValueChangeEventArgs) m_Chart.BeginAngle = New NAngle(CType(arg.TargetNode, NNumericUpDown).Value, NUnit.Degree) End Sub Private Sub OnTitleAngleModeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs) For i = 0 To m_Chart.Axes.Count - 1 Dim oldTitleAngle As NScaleLabelAngle = m_Chart.Axes(CInt(i)).TitleAngle m_Chart.Axes(i).TitleAngle = New NScaleLabelAngle(CType(arg.TargetNode, NComboBox).SelectedIndex, oldTitleAngle.CustomAngle) Next End Sub Private Sub OnTitleAngleUpDownValueChanged(arg As NValueChangeEventArgs) For i = 0 To m_Chart.Axes.Count - 1 Dim oldTitleAngle As NScaleLabelAngle = m_Chart.Axes(CInt(i)).TitleAngle m_Chart.Axes(i).TitleAngle = New NScaleLabelAngle(oldTitleAngle.LabelAngleMode, CType(arg.TargetNode, NNumericUpDown).Value) Next End Sub #End Region #Region "Fields" Private m_Chart As NRadarChart Private m_RadarLine1 As NRadarLineSeries Private m_RadarLine2 As NRadarLineSeries #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) Radar Line Example for WPF Solution

Related Documentation Links