Radar Area Example for Blazor

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

Radar Area Example for Blazor Description

This example demonstrates how to create a radar area chart.


Radar Area Example

C# Radar Area Example Code for Nevron Chart for Blazor
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 - NRadarAreaExample";

			// 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 Area";

			// 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_RadarArea1 = new NRadarAreaSeries();
			m_Chart.Series.Add(m_RadarArea1);
			m_RadarArea1.Stroke = new NStroke(2, NChartPalette.BrightPalette[0]);
			m_RadarArea1.Name = "Series 1";
			m_RadarArea1.DataLabelStyle = new NDataLabelStyle(false);

			m_RadarArea2 = new NRadarAreaSeries();
			m_Chart.Series.Add(m_RadarArea2);
			m_RadarArea2.Stroke = new NStroke(2, NChartPalette.BrightPalette[1]);
			m_RadarArea2.Name = "Series 2";
			m_RadarArea2.DataLabelStyle = new NDataLabelStyle(false);

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

			for (int i = 0; i < 8; i++)
			{
				m_RadarArea1.DataPoints.Add(new NRadarAreaDataPoint(random.Next(50, 90)));
				m_RadarArea2.DataPoints.Add(new NRadarAreaDataPoint(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 area chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Radar Area Series", "https://www.nevron.com/docs/openvision/radar-area-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; NRadarAreaSeries m_RadarArea1; NRadarAreaSeries m_RadarArea2; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Radar Area Example for Blazor Solution

Related Documentation Links