This example demonstrates how to control the polar angle 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 - NPolarAngleAxisPositionExample";
// 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 Angle Axis Position";
// configure chart
m_Chart = (NPolarChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleSecondaryAngleValue);
// setup chart
m_Chart.InnerRadius = 40;
// create a polar line series
NPolarLineSeries series1 = new NPolarLineSeries();
m_Chart.Series.Add(series1);
series1.Name = "Series 1";
series1.CloseContour = true;
series1.DataLabelStyle = new NDataLabelStyle(false);
series1.MarkerStyle = new NMarkerStyle(false);
series1.UseXValues = true;
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.DataLabelStyle = new NDataLabelStyle(false);
series2.MarkerStyle = new NMarkerStyle(false);
series2.UseXValues = true;
Curve2(series2, 100);
// setup polar axis
NLinearScale linearScale = (NLinearScale)m_Chart.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
NAngularScale degreeScale = (NAngularScale)m_Chart.Axes[ENPolarAxis.PrimaryAngle].Scale;
degreeScale.MajorGridLines.Visible = true;
degreeScale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
// add a second value axes
NPolarAxis valueAxis = m_Chart.Axes[ENPolarAxis.PrimaryValue];
m_RedAxis = m_Chart.Axes[ENPolarAxis.PrimaryAngle];
m_GreenAxis = m_Chart.Axes[ENPolarAxis.SecondaryAngle];
NAngularScale gradScale = new NAngularScale();
gradScale.AngleUnit = NUnit.Grad;
gradScale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0);
m_GreenAxis.Scale = gradScale;
NValueAxisCrossing greenAxisCrossing = new NValueAxisCrossing(m_RedAxis, 70);
NCrossPolarAxisAnchor greenCrossAnchor = new NCrossPolarAxisAnchor(greenAxisCrossing, ENPolarAxisOrientation.Angle, ENScaleOrientation.Right);
m_GreenAxis.Anchor = greenCrossAnchor;
m_RedAxis.Anchor = new NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim);
NValueAxisCrossing redAxisCrossing = new NValueAxisCrossing(m_RedAxis, 90);
NCrossPolarAxisAnchor redCrossAnchor = new NCrossPolarAxisAnchor(redAxisCrossing, ENPolarAxisOrientation.Value, ENScaleOrientation.Auto);
m_Chart.Axes[ENPolarAxis.PrimaryValue].Anchor = redCrossAnchor;
// apply style sheet
// color code the axes and series after the stylesheet is applied
m_RedAxis.Scale.SetColor(NColor.Red);
m_GreenAxis.Scale.SetColor(NColor.Green);
m_GreenAxis.VisibilityMode = ENAxisVisibilityMode.Visible;
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));
// red axis controls
stack.Add(new NLabel("Degree Axis (Red):"));
NCheckBox dockRedAxisCheckBox = new NCheckBox("Dock");
stack.Add(dockRedAxisCheckBox);
m_RedAxisCrossValueUpDown = new NNumericUpDown();
stack.Add(NPairBox.Create("Cross Value:", m_RedAxisCrossValueUpDown));
// green axis controls
stack.Add(new NLabel("Grad Axis (Green):"));
NCheckBox dockGreenAxisCheckBox = new NCheckBox("Dock");
stack.Add(dockGreenAxisCheckBox);
m_GreenAxisCrossValueUpDown = new NNumericUpDown();
stack.Add(NPairBox.Create("Cross Value:", m_GreenAxisCrossValueUpDown));
// wire events
dockRedAxisCheckBox.CheckedChanged += OnDockRedAxisCheckBoxCheckedChanged;
m_RedAxisCrossValueUpDown.ValueChanged += OnRedAxisCrossValueUpDownValueChanged;
dockGreenAxisCheckBox.CheckedChanged += OnDockGreenAxisCheckBoxCheckedChanged;
m_GreenAxisCrossValueUpDown.ValueChanged += OnGreenAxisCrossValueUpDownValueChanged;
// init values
m_RedAxisCrossValueUpDown.Value = 50;
dockRedAxisCheckBox.Checked = true;
dockGreenAxisCheckBox.Checked = false;
m_GreenAxisCrossValueUpDown.Value = 70;
return group;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to control the polar angle 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 = 100 * Math.Cos(angle);
series.DataPoints.Add(new NPolarLineDataPoint(angle * 180 / 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 = 33 + 100 * Math.Sin(2 * angle) + 1.7 * Math.Cos(2 * angle);
radius = Math.Abs(radius);
series.DataPoints.Add(new NPolarLineDataPoint(angle * 180 / Math.PI, radius));
}
}
#endregion
#region Event Handlers
void OnBeginAngleUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Chart.BeginAngle = new NAngle(((NNumericUpDown)arg.TargetNode).Value, NUnit.Degree);
}
void OnDockGreenAxisCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
if (((NCheckBox)arg.TargetNode).Checked)
{
m_GreenAxis.Anchor = new NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim);
m_GreenAxisCrossValueUpDown.Enabled = false;
}
else
{
NCrossPolarAxisAnchor axisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto);
axisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryValue], m_GreenAxisCrossValueUpDown.Value);
m_GreenAxis.Anchor = axisAnchor;
m_GreenAxisCrossValueUpDown.Enabled = true;
}
}
void OnGreenAxisCrossValueUpDownValueChanged(NValueChangeEventArgs arg)
{
NCrossPolarAxisAnchor axisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto);
axisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryValue], m_GreenAxisCrossValueUpDown.Value);
m_GreenAxis.Anchor = axisAnchor;
}
void OnDockRedAxisCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
if (((NCheckBox)arg.TargetNode).Checked)
{
m_RedAxis.Anchor = new NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim);
m_RedAxisCrossValueUpDown.Enabled = false;
}
else
{
NCrossPolarAxisAnchor axisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto);
axisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryValue], m_RedAxisCrossValueUpDown.Value);
m_RedAxis.Anchor = axisAnchor;
m_RedAxisCrossValueUpDown.Enabled = true;
}
}
void OnRedAxisCrossValueUpDownValueChanged(NValueChangeEventArgs arg)
{
NCrossPolarAxisAnchor axisAnchor = new NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto);
axisAnchor.Crossing = new NValueAxisCrossing(m_Chart.Axes[ENPolarAxis.PrimaryValue], m_RedAxisCrossValueUpDown.Value);
m_RedAxis.Anchor = axisAnchor;
}
#endregion
#region Fields
NPolarChart m_Chart;
NPolarAxis m_RedAxis;
NPolarAxis m_GreenAxis;
NNumericUpDown m_GreenAxisCrossValueUpDown;
NNumericUpDown m_RedAxisCrossValueUpDown;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Imports System
Class MainWindow
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Title = "NOV WPF - NPolarAngleAxisPositionExample"
' Create the NOV example and its controls
Dim exampleContent As NWidget = CreateExampleContent()
Dim exampleControls As NWidget = CreateExampleControls()
If Not exampleControls Is Nothing Then
exampleControls.PreferredWidth = 300
End If
' Place the example and its controls in a pair box
Dim pairBox As NPairBox = 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
Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
Content = host
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
Dim chartView = chartViewWithCommandBars.View
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Polar)
' configure title
chartView.Surface.Titles(0).Text = "Polar Angle Axis Position"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NPolarChart)
m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleSecondaryAngleValue)
' setup chart
m_Chart.InnerRadius = 40
' create a polar line series
Dim series1 As NPolarLineSeries = New NPolarLineSeries()
m_Chart.Series.Add(series1)
series1.Name = "Series 1"
series1.CloseContour = True
series1.DataLabelStyle = New NDataLabelStyle(False)
series1.MarkerStyle = New NMarkerStyle(False)
series1.UseXValues = True
Curve1(series1, 50)
' create a polar line series
Dim series2 As NPolarLineSeries = New NPolarLineSeries()
m_Chart.Series.Add(series2)
series2.Name = "Series 2"
series2.CloseContour = True
series2.DataLabelStyle = New NDataLabelStyle(False)
series2.MarkerStyle = New NMarkerStyle(False)
series2.UseXValues = True
Curve2(series2, 100)
' setup polar axis
Dim linearScale As NLinearScale = m_Chart.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)
Dim strip As NScaleStrip = New NScaleStrip()
strip.Fill = New NColorFill(NColor.Beige)
strip.Interlaced = True
linearScale.Strips.Add(strip)
' setup polar angle axis
Dim degreeScale As NAngularScale = m_Chart.Axes(ENPolarAxis.PrimaryAngle).Scale
degreeScale.MajorGridLines.Visible = True
degreeScale.Labels.Style.Angle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0)
' add a second value axes
Dim valueAxis = m_Chart.Axes(ENPolarAxis.PrimaryValue)
m_RedAxis = m_Chart.Axes(ENPolarAxis.PrimaryAngle)
m_GreenAxis = m_Chart.Axes(ENPolarAxis.SecondaryAngle)
Dim gradScale As NAngularScale = New NAngularScale()
gradScale.AngleUnit = NUnit.Grad
gradScale.Labels.Style.Angle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0)
m_GreenAxis.Scale = gradScale
Dim greenAxisCrossing As NValueAxisCrossing = New NValueAxisCrossing(m_RedAxis, 70)
Dim greenCrossAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(greenAxisCrossing, ENPolarAxisOrientation.Angle, ENScaleOrientation.Right)
m_GreenAxis.Anchor = greenCrossAnchor
m_RedAxis.Anchor = New NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim)
Dim redAxisCrossing As NValueAxisCrossing = New NValueAxisCrossing(m_RedAxis, 90)
Dim redCrossAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(redAxisCrossing, ENPolarAxisOrientation.Value, ENScaleOrientation.Auto)
m_Chart.Axes(ENPolarAxis.PrimaryValue).Anchor = redCrossAnchor
' apply style sheet
' color code the axes and series after the stylesheet is applied
m_RedAxis.Scale.SetColor(NColor.Red)
m_GreenAxis.Scale.SetColor(NColor.Green)
m_GreenAxis.VisibilityMode = ENAxisVisibilityMode.Visible
series2.ValueAxis = m_GreenAxis
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
' begin angle
Dim beginAngleUpDown As NNumericUpDown = New NNumericUpDown()
beginAngleUpDown.ValueChanged += AddressOf OnBeginAngleUpDownValueChanged
stack.Add(NPairBox.Create("Begin Angle:", beginAngleUpDown))
' red axis controls
stack.Add(New NLabel("Degree Axis (Red):"))
Dim dockRedAxisCheckBox As NCheckBox = New NCheckBox("Dock")
stack.Add(dockRedAxisCheckBox)
m_RedAxisCrossValueUpDown = New NNumericUpDown()
stack.Add(NPairBox.Create("Cross Value:", m_RedAxisCrossValueUpDown))
' green axis controls
stack.Add(New NLabel("Grad Axis (Green):"))
Dim dockGreenAxisCheckBox As NCheckBox = New NCheckBox("Dock")
stack.Add(dockGreenAxisCheckBox)
m_GreenAxisCrossValueUpDown = New NNumericUpDown()
stack.Add(NPairBox.Create("Cross Value:", m_GreenAxisCrossValueUpDown))
' wire events
dockRedAxisCheckBox.CheckedChanged += AddressOf OnDockRedAxisCheckBoxCheckedChanged
Me.m_RedAxisCrossValueUpDown.ValueChanged += AddressOf OnRedAxisCrossValueUpDownValueChanged
dockGreenAxisCheckBox.CheckedChanged += AddressOf OnDockGreenAxisCheckBoxCheckedChanged
Me.m_GreenAxisCrossValueUpDown.ValueChanged += AddressOf OnGreenAxisCrossValueUpDownValueChanged
' init values
m_RedAxisCrossValueUpDown.Value = 50
dockRedAxisCheckBox.Checked = True
dockGreenAxisCheckBox.Checked = False
m_GreenAxisCrossValueUpDown.Value = 70
Return group
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to control the polar angle axis position.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("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")}
End Function
#End Region
#Region "Implementation"
Friend Shared Sub Curve1(series As NPolarLineSeries, count As Integer)
series.DataPoints.Clear()
Dim angleStep = 2 * Math.PI / count
For i = 0 To count - 1
Dim angle = i * angleStep
Dim radius = 100 * Math.Cos(angle)
series.DataPoints.Add(New NPolarLineDataPoint(angle * 180 / Math.PI, radius))
Next
End Sub
Friend Shared Sub Curve2(series As NPolarLineSeries, count As Integer)
series.DataPoints.Clear()
Dim angleStep = 2 * Math.PI / count
For i = 0 To count - 1
Dim angle = i * angleStep
Dim radius = 33 + 100 * Math.Sin(2 * angle) + 1.7 * Math.Cos(2 * angle)
radius = Math.Abs(radius)
series.DataPoints.Add(New NPolarLineDataPoint(angle * 180 / Math.PI, radius))
Next
End Sub
#End Region
#Region "Event Handlers"
Private Sub OnBeginAngleUpDownValueChanged(arg As NValueChangeEventArgs)
m_Chart.BeginAngle = New NAngle(CType(arg.TargetNode, NNumericUpDown).Value, NUnit.Degree)
End Sub
Private Sub OnDockGreenAxisCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
If CType(arg.TargetNode, NCheckBox).Checked Then
m_GreenAxis.Anchor = New NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim)
m_GreenAxisCrossValueUpDown.Enabled = False
Else
Dim axisAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto)
axisAnchor.Crossing = New NValueAxisCrossing(m_Chart.Axes(ENPolarAxis.PrimaryValue), m_GreenAxisCrossValueUpDown.Value)
m_GreenAxis.Anchor = axisAnchor
m_GreenAxisCrossValueUpDown.Enabled = True
End If
End Sub
Private Sub OnGreenAxisCrossValueUpDownValueChanged(arg As NValueChangeEventArgs)
Dim axisAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto)
axisAnchor.Crossing = New NValueAxisCrossing(m_Chart.Axes(ENPolarAxis.PrimaryValue), m_GreenAxisCrossValueUpDown.Value)
m_GreenAxis.Anchor = axisAnchor
End Sub
Private Sub OnDockRedAxisCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
If CType(arg.TargetNode, NCheckBox).Checked Then
m_RedAxis.Anchor = New NDockPolarAxisAnchor(ENPolarAxisDockZone.OuterRim)
m_RedAxisCrossValueUpDown.Enabled = False
Else
Dim axisAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto)
axisAnchor.Crossing = New NValueAxisCrossing(m_Chart.Axes(ENPolarAxis.PrimaryValue), m_RedAxisCrossValueUpDown.Value)
m_RedAxis.Anchor = axisAnchor
m_RedAxisCrossValueUpDown.Enabled = True
End If
End Sub
Private Sub OnRedAxisCrossValueUpDownValueChanged(arg As NValueChangeEventArgs)
Dim axisAnchor As NCrossPolarAxisAnchor = New NCrossPolarAxisAnchor(ENPolarAxisOrientation.Angle, ENScaleOrientation.Auto)
axisAnchor.Crossing = New NValueAxisCrossing(m_Chart.Axes(ENPolarAxis.PrimaryValue), m_RedAxisCrossValueUpDown.Value)
m_RedAxis.Anchor = axisAnchor
End Sub
#End Region
#Region "Fields"
Private m_Chart As NPolarChart
Private m_RedAxis As NPolarAxis
Private m_GreenAxis As NPolarAxis
Private m_GreenAxisCrossValueUpDown As NNumericUpDown
Private m_RedAxisCrossValueUpDown As NNumericUpDown
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class