This example demonstrates how to control the polar value axis position.

| 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 - NPolarValueAxisPositionExample";
// 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 Value Axis Position";
// configure chart
m_Chart = (NPolarChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue);
// setup chart
m_Chart.InnerRadius = 20;
// setup polar axis
NLinearScale linearScale = (NLinearScale)m_Chart.Axes[ENPolarAxis.PrimaryValue].Scale;
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
linearScale.InflateViewRangeBegin = true;
linearScale.InflateViewRangeEnd = true;
linearScale.Labels.OverlapResolveLayouts = new NDomArray(new ENLevelLabelsLayout[] { ENLevelLabelsLayout.AutoScale });
linearScale.MajorGridLines.Visible = true;
linearScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dash;
NScaleStrip strip = new NScaleStrip();
strip.Fill = new NColorFill(NColor.Beige);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// setup polar angle axis
NAngularScale angularScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;
angularScale.MajorGridLines.Visible = true;
angularScale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
// add a const line
NAxisReferenceLine referenceLine = new NAxisReferenceLine();
referenceLine.Value = 1.0;
referenceLine.Stroke = new NStroke(1, NColor.SlateBlue);
m_Chart.Axes[ENPolarAxis.PrimaryValue].ReferenceLines.Add(referenceLine);
// create a polar line series
NPolarLineSeries series1 = new NPolarLineSeries();
m_Chart.Series.Add(series1);
series1.Name = "Series 1";
series1.CloseContour = true;
series1.UseXValues = true;
series1.DataLabelStyle = new NDataLabelStyle(false);
NMarkerStyle markerStyle = new NMarkerStyle();
markerStyle.Visible = false;
markerStyle.Size = new NSize(2, 2);
series1.MarkerStyle = markerStyle;
Curve1(series1, 50);
// create a polar line series
NPolarLineSeries series2 = new NPolarLineSeries();
m_Chart.Series.Add(series2);
series2.Name = "Series 2";
series2.CloseContour = true;
series2.UseXValues = true;
series2.DataLabelStyle = new NDataLabelStyle(false);
markerStyle = new NMarkerStyle();
markerStyle.Visible = false;
series2.MarkerStyle = markerStyle;
Curve2(series2, 100);
// add a second value axes
m_RedAxis = m_Chart.Axes[ENPolarAxis.PrimaryValue];
m_GreenAxis = m_Chart.AddCustomAxis(ENPolarAxisOrientation.Value);
NCrossPolarAxisAnchor redAxisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Value, ENScaleOrientation.Auto);
redAxisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryAngle], 0.0f);
m_RedAxis.Anchor = redAxisAnchor;
NCrossPolarAxisAnchor greenAxisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Value, ENScaleOrientation.Auto);
greenAxisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryAngle], 90);
m_GreenAxis.Anchor = greenAxisAnchor;
// color code the axes and series after the stylesheet is applied
m_RedAxis.Scale.SetColor(NColor.Red);
m_GreenAxis.Scale.SetColor(NColor.Green);
series1.Stroke = new NStroke(2, NColor.DarkRed);
series2.Stroke = new NStroke(2, NColor.DarkGreen);
series2.ValueAxis = m_GreenAxis;
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
// begin angle
NNumericUpDown beginAngleUpDown = new NNumericUpDown();
beginAngleUpDown.ValueChanged += OnBeginAngleUpDownValueChanged;
stack.Add(NPairBox.Create("Begin Angle:", beginAngleUpDown));
// radian angle step
NComboBox radianAngleStepComboBox = new NComboBox();
radianAngleStepComboBox.Items.Add(new NComboBoxItem("15"));
radianAngleStepComboBox.Items.Add(new NComboBoxItem("30"));
radianAngleStepComboBox.Items.Add(new NComboBoxItem("45"));
radianAngleStepComboBox.Items.Add(new NComboBoxItem("90"));
radianAngleStepComboBox.SelectedIndexChanged += OnRadianAngleStepComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Radian Angle Step", radianAngleStepComboBox));
// red axis position
stack.Add(new NLabel("Red Axis:"));
{
NCheckBox dockRedAxisToBottomCheckBox = new NCheckBox("Dock Bottom");
dockRedAxisToBottomCheckBox.CheckedChanged += OnDockRedAxisToBottomCheckBoxCheckedChanged;
stack.Add(dockRedAxisToBottomCheckBox);
m_RedAxisAngleUpDown = new NNumericUpDown();
m_RedAxisAngleUpDown.Value = 0;
m_RedAxisAngleUpDown.ValueChanged += OnRedAxisAngleUpDownValueChanged;
stack.Add(NPairBox.Create("Angle:", m_RedAxisAngleUpDown));
NCheckBox redAxisPaintRefelectionCheckBox = new NCheckBox("Paint Reflection");
redAxisPaintRefelectionCheckBox.Checked = true;
redAxisPaintRefelectionCheckBox.CheckedChanged += OnRedAxisPaintRefelectionCheckBoxCheckedChanged;
stack.Add(redAxisPaintRefelectionCheckBox);
m_RedAxisScaleLabelAngleMode = new NComboBox();
m_RedAxisScaleLabelAngleMode.Items.FillFromEnum();
m_RedAxisScaleLabelAngleMode.SelectedIndex = (int)ENScaleLabelAngleMode.View;
m_RedAxisScaleLabelAngleMode.SelectedIndexChanged += OnUpdateRedAxisSaleLabelAngle;
stack.Add(NPairBox.Create("Scale Label Angle Mode:", m_RedAxisScaleLabelAngleMode));
m_RedAxisSaleLabelAngleUpDown = new NNumericUpDown();
m_RedAxisSaleLabelAngleUpDown.ValueChanged += OnUpdateRedAxisSaleLabelAngle;
stack.Add(NPairBox.Create("Scale Label Angle:", m_RedAxisSaleLabelAngleUpDown));
NNumericUpDown redAxisBeginPercentUpDown = new NNumericUpDown();
redAxisBeginPercentUpDown.Value = m_RedAxis.Anchor.BeginPercent;
redAxisBeginPercentUpDown.ValueChanged += OnRedAxisBeginPercentUpDownValueChanged;
stack.Add(NPairBox.Create("Begin percent:", redAxisBeginPercentUpDown));
NNumericUpDown redAxisEndPercentUpDown = new NNumericUpDown();
redAxisEndPercentUpDown.Value = m_RedAxis.Anchor.EndPercent;
redAxisEndPercentUpDown.ValueChanged += OnRedAxisEndPercentUpDownValueChanged;
stack.Add(NPairBox.Create("End percent:", redAxisEndPercentUpDown));
}
// green axis position
stack.Add(new NLabel("Green Axis:"));
{
NCheckBox dockGreenAxisToLeftCheckBox = new NCheckBox("Dock Left");
dockGreenAxisToLeftCheckBox.CheckedChanged += OnDockGreenAxisToLeftCheckBoxCheckedChanged;
stack.Add(dockGreenAxisToLeftCheckBox);
m_GreenAxisAngleUpDown = new NNumericUpDown();
m_GreenAxisAngleUpDown.Value = 90;
m_GreenAxisAngleUpDown.ValueChanged += OnGreenAxisAngleUpDownValueChanged;
stack.Add(NPairBox.Create("Angle:", m_GreenAxisAngleUpDown));
NCheckBox greenAxisPaintRefelectionCheckBox = new NCheckBox("Paint Reflection");
greenAxisPaintRefelectionCheckBox.Checked = true;
greenAxisPaintRefelectionCheckBox.CheckedChanged += OnGreenAxisPaintRefelectionCheckBoxCheckedChanged;
stack.Add(greenAxisPaintRefelectionCheckBox);
m_GreenAxisScaleLabelAngleMode = new NComboBox();
m_GreenAxisScaleLabelAngleMode.Items.FillFromEnum();
m_GreenAxisScaleLabelAngleMode.SelectedIndex = (int)ENScaleLabelAngleMode.View;
m_GreenAxisScaleLabelAngleMode.SelectedIndexChanged += OnUpdateGreenAxisSaleLabelAngle;
stack.Add(NPairBox.Create("Scale Label Angle Mode:", m_GreenAxisScaleLabelAngleMode));
m_GreenAxisSaleLabelAngleUpDown = new NNumericUpDown();
m_GreenAxisSaleLabelAngleUpDown.ValueChanged += OnUpdateGreenAxisSaleLabelAngle;
stack.Add(NPairBox.Create("Scale Label Angle:", m_GreenAxisSaleLabelAngleUpDown));
NNumericUpDown greenAxisBeginPercentUpDown = new NNumericUpDown();
greenAxisBeginPercentUpDown.Value = m_GreenAxis.Anchor.BeginPercent;
greenAxisBeginPercentUpDown.ValueChanged += OnGreenAxisBeginPercentUpDownValueChanged;
stack.Add(NPairBox.Create("Begin percent:", greenAxisBeginPercentUpDown));
NNumericUpDown greenAxisEndPercentUpDown = new NNumericUpDown();
greenAxisEndPercentUpDown.Value = m_GreenAxis.Anchor.EndPercent;
greenAxisEndPercentUpDown.ValueChanged += OnGreenAxisEndPercentUpDownValueChanged;
stack.Add(NPairBox.Create("End percent:", greenAxisEndPercentUpDown));
}
return group;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to control the polar value axis position.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Polar Axes", "https://www.nevron.com/docs/openvision/polar-chart-axes.html"),
("Common Axis Functionality", "https://www.nevron.com/docs/openvision/chart-common-axis-functionality.html"),
};
}
#endregion
#region Implementation
internal static void Curve1(NPolarLineSeries series, int count)
{
series.DataPoints.Clear();
double angleStep = 2 * Math.PI / count;
for (int i = 0; i < count; i++)
{
double angle = i * angleStep;
double radius = 1 + Math.Cos(angle);
series.DataPoints.Add(new NPolarLineDataPoint((double)(angle * 180.0 / Math.PI), radius));
}
}
internal static void Curve2(NPolarLineSeries series, int count)
{
series.DataPoints.Clear();
double angleStep = 2 * Math.PI / count;
for (int i = 0; i < count; i++)
{
double angle = i * angleStep;
double radius = 0.2 + 1.7 * Math.Sin(2 * angle) + 1.7 * Math.Cos(2 * angle);
radius = Math.Abs(radius);
series.DataPoints.Add(new NPolarLineDataPoint((double)angle * 180.0 / Math.PI, radius));
}
}
#endregion
#region Event Handlers
void OnUpdateGreenAxisSaleLabelAngle(NValueChangeEventArgs arg)
{
(m_GreenAxis.Scale as NLinearScale).Labels.Style.Angle = new NScaleLabelAngle((ENScaleLabelAngleMode)m_GreenAxisScaleLabelAngleMode.SelectedIndex, m_GreenAxisSaleLabelAngleUpDown.Value);
}
void OnGreenAxisPaintRefelectionCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_GreenAxis.PaintReflection = ((NCheckBox)arg.TargetNode).Checked;
}
void OnGreenAxisEndPercentUpDownValueChanged(NValueChangeEventArgs arg)
{
m_GreenAxis.Anchor.EndPercent = (float)((NNumericUpDown)arg.TargetNode).Value;
}
void OnGreenAxisBeginPercentUpDownValueChanged(NValueChangeEventArgs arg)
{
m_GreenAxis.Anchor.BeginPercent = (float)((NNumericUpDown)arg.TargetNode).Value;
}
void OnGreenAxisAngleUpDownValueChanged(NValueChangeEventArgs arg)
{
NCrossPolarAxisAnchor valueCrossPolarAnchor = m_GreenAxis.Anchor as NCrossPolarAxisAnchor;
if (valueCrossPolarAnchor != null)
{
((NValueAxisCrossing)valueCrossPolarAnchor.Crossing).Value = m_GreenAxisAngleUpDown.Value;
}
}
void OnDockGreenAxisToLeftCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
if (((NCheckBox)arg.TargetNode).Checked)
{
m_GreenAxis.Anchor = new NDockPolarAxisAnchor(ENPolarAxisDockZone.Left);
m_GreenAxisAngleUpDown.Enabled = false;
}
else
{
NCrossPolarAxisAnchor anchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Value, ENScaleOrientation.Auto);
anchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryAngle], m_GreenAxisAngleUpDown.Value);
m_GreenAxis.Anchor = anchor;
m_GreenAxisAngleUpDown.Enabled = true;
}
}
void OnUpdateRedAxisSaleLabelAngle(NValueChangeEventArgs arg)
{
(m_RedAxis.Scale as NLinearScale).Labels.Style.Angle = new NScaleLabelAngle((ENScaleLabelAngleMode)m_RedAxisScaleLabelAngleMode.SelectedIndex, m_RedAxisSaleLabelAngleUpDown.Value);
}
void OnRedAxisPaintRefelectionCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_RedAxis.PaintReflection = ((NCheckBox)arg.TargetNode).Checked;
}
void OnRedAxisEndPercentUpDownValueChanged(NValueChangeEventArgs arg)
{
m_RedAxis.Anchor.EndPercent = (float)((NNumericUpDown)arg.TargetNode).Value;
}
void OnRedAxisBeginPercentUpDownValueChanged(NValueChangeEventArgs arg)
{
m_RedAxis.Anchor.BeginPercent = (float)((NNumericUpDown)arg.TargetNode).Value;
}
void OnRedAxisAngleUpDownValueChanged(NValueChangeEventArgs arg)
{
NCrossPolarAxisAnchor valueCrossPolarAnchor = m_RedAxis.Anchor as NCrossPolarAxisAnchor;
if (valueCrossPolarAnchor != null)
{
((NValueAxisCrossing)valueCrossPolarAnchor.Crossing).Value = m_RedAxisAngleUpDown.Value;
}
}
void OnDockRedAxisToBottomCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
if (((NCheckBox)arg.TargetNode).Checked)
{
m_RedAxis.Anchor = new NDockPolarAxisAnchor(ENPolarAxisDockZone.Bottom);
m_RedAxisAngleUpDown.Enabled = false;
}
else
{
NCrossPolarAxisAnchor anchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Value, ENScaleOrientation.Auto);
anchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryAngle], m_RedAxisAngleUpDown.Value);
m_RedAxis.Anchor = anchor;
m_RedAxisAngleUpDown.Enabled = true;
}
}
void OnRadianAngleStepComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
NAngularScale angleScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;
angleScale.MajorTickMode = ENMajorTickMode.CustomStep;
switch (((NComboBox)arg.TargetNode).SelectedIndex)
{
case 0:
angleScale.CustomStep = new NAngle(15, NUnit.Degree);
break;
case 1:
angleScale.CustomStep = new NAngle(30, NUnit.Degree);
break;
case 2:
angleScale.CustomStep = new NAngle(45, NUnit.Degree);
break;
case 3:
angleScale.CustomStep = new NAngle(90, NUnit.Degree);
break;
default:
NDebug.Assert(false);
break;
}
}
void OnBeginAngleUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Chart.BeginAngle = new NAngle(((NNumericUpDown)arg.TargetNode).Value, NUnit.Degree);
}
#endregion
#region Fields
NPolarChart m_Chart;
NPolarAxis m_RedAxis;
NPolarAxis m_GreenAxis;
NNumericUpDown m_RedAxisAngleUpDown;
NNumericUpDown m_GreenAxisAngleUpDown;
NNumericUpDown m_RedAxisSaleLabelAngleUpDown;
NComboBox m_RedAxisScaleLabelAngleMode;
NNumericUpDown m_GreenAxisSaleLabelAngleUpDown;
NComboBox m_GreenAxisScaleLabelAngleMode;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
}