This example demonstrates how to create a polar area chart.

| 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 - NPolarAreaExample";
// 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 Area";
// 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;
NScaleStrip strip = new NScaleStrip();
strip.Fill = new NColorFill(NColor.FromColor(NColor.Beige, 0.5f));
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// setup polar angle axis
NAngularScale angularScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;
// polar area series 1
NPolarAreaSeries series1 = new NPolarAreaSeries();
m_Chart.Series.Add(series1);
series1.Name = "Theoretical";
series1.DataLabelStyle = new NDataLabelStyle(false);
GenerateData(series1, 100, 15.0);
// polar area series 2
NPolarAreaSeries series2 = new NPolarAreaSeries();
m_Chart.Series.Add(series2);
series2.Name = "Experimental";
series2.DataLabelStyle = new NDataLabelStyle(false);
GenerateData(series2, 100, 10.0);
// apply style sheet
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 area chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Polar Area Series", "https://www.nevron.com/docs/openvision/polar-area-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 void GenerateData(NPolarAreaSeries series, int count, double scale)
{
series.DataPoints.Clear();
double angleStep = 2 * Math.PI / count;
Random random = new Random();
for (int i = 0; i < count; i++)
{
double angle = i * angleStep;
double c1 = 1.0 * Math.Sin(angle * 3);
double c2 = 0.3 * Math.Sin(angle * 1.5);
double c3 = 0.05 * Math.Cos(angle * 26);
double c4 = 0.05 * (0.5 - random.NextDouble());
double value = scale * (Math.Abs(c1 + c2 + c3) + c4);
if (value < 0)
value = 0;
series.DataPoints.Add(new NPolarAreaDataPoint(angle * 180 / Math.PI, value));
}
}
#endregion
#region Event Handlers
#endregion
#region Fields
NPolarChart m_Chart;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
}