This example demonstrates how to create a polar point 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 - 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
}
}