This example demonstrates how to create an angular scale.

| 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 - NAngularScaleExample";
// 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 = "Angular Scale";
// configure chart
NPolarChart polarChart = (NPolarChart)chartView.Surface.Charts[0];
polarChart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue);
NAngularScale angularScale = new NAngularScale();
polarChart.Axes[ENPolarAxis.PrimaryAngle].Scale = angularScale;
// setup chart
polarChart.InnerRadius = 40;
// create a polar line series
NPolarLineSeries polarLine = new NPolarLineSeries();
polarChart.Series.Add(polarLine);
polarLine.Name = "Series 1";
polarLine.CloseContour = true;
polarLine.DataLabelStyle = new NDataLabelStyle(false);
polarLine.MarkerStyle = new NMarkerStyle(false);
polarLine.UseXValues = true;
int count = 50;
double angleStep = 2 * Math.PI / count;
for (int i = 0; i < count; i++)
{
double angle = i * angleStep;
double radius = 100 * Math.Cos(angle);
polarLine.DataPoints.Add(new NPolarLineDataPoint(angle * 180 / Math.PI, radius));
}
// setup polar axis
NLinearScale linearScale = (NLinearScale)polarChart.Axes[ENPolarAxis.PrimaryValue].Scale;
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
linearScale.InflateViewRangeBegin = true;
linearScale.InflateViewRangeEnd = true;
linearScale.MajorGridLines.Visible = true;
linearScale.MajorGridLines.Stroke = new NStroke(1, NColor.Gray, ENDashStyle.Solid);
NScaleStrip strip = new NScaleStrip();
strip.Fill = new NColorFill(NColor.Beige);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// setup polar angle axis
m_AngularScale = (NAngularScale)polarChart.Axes[ENPolarAxis.PrimaryAngle].Scale;
m_AngularScale.MajorGridLines.Visible = true;
m_AngularScale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
// add a second value axes
NPolarAxis valueAxis = polarChart.Axes[ENPolarAxis.PrimaryValue];
NAngularScale gradScale = new NAngularScale();
gradScale.AngleUnit = NUnit.Grad;
gradScale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NComboBox angleUnitComboBox = new NComboBox();
angleUnitComboBox.Items.Add("Degree");
angleUnitComboBox.Items.Add("Grad");
angleUnitComboBox.DropDownStyle = ENComboBoxStyle.DropDownList;
angleUnitComboBox.SelectedIndexChanged += OnAngleUnitComboBoxSelectedIndexChanged;
angleUnitComboBox.SelectedIndex = 0;
stack.Add(NPairBox.Create("Angle Unit:", angleUnitComboBox));
NNumericUpDown minTickDistance = new NNumericUpDown();
minTickDistance.Minimum = 10;
minTickDistance.Maximum = 100;
minTickDistance.ValueChanged += OnMinTickDistanceValueChanged;
minTickDistance.Value = 20;
stack.Add(NPairBox.Create("Min Tick Distnace:", minTickDistance));
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create an angular scale.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Angular Scale", "https://www.nevron.com/docs/openvision/angular-scale.html"),
("Polar Axes", "https://www.nevron.com/docs/openvision/polar-chart-axes.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
private void OnMinTickDistanceValueChanged(NValueChangeEventArgs arg)
{
m_AngularScale.MajorTickMode = ENMajorTickMode.AutoMinDistance;
m_AngularScale.MinTickDistance = (double)arg.NewValue;
}
private void OnAngleUnitComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
switch (arg.NewValue)
{
case 0:
m_AngularScale.AngleUnit = NUnit.Degree;
break;
case 1:
m_AngularScale.AngleUnit = NUnit.Grad;
break;
}
}
#endregion
#region Fields
NAngularScale m_AngularScale;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
}