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
}
} | 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.Forms
Imports System
Public Class Form1
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Text = "NOV WinForms - NAngularScaleExample"
' 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)
host.Dock = DockStyle.Fill
Controls.Add(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 = "Angular Scale"
' configure chart
Dim polarChart = CType(chartView.Surface.Charts(0), NPolarChart)
polarChart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue)
Dim angularScale As NAngularScale = New NAngularScale()
polarChart.Axes(ENPolarAxis.PrimaryAngle).Scale = angularScale
' setup chart
polarChart.InnerRadius = 40
' create a polar line series
Dim polarLine As NPolarLineSeries = 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
Dim count = 50
Dim angleStep = 2 * Math.PI / count
For i = 0 To count - 1
Dim angle = i * angleStep
Dim radius = 100 * Math.Cos(angle)
polarLine.DataPoints.Add(New NPolarLineDataPoint(angle * 180 / Math.PI, radius))
Next
' setup polar axis
Dim linearScale As 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)
Dim strip As NScaleStrip = New NScaleStrip()
strip.Fill = New NColorFill(NColor.Beige)
strip.Interlaced = True
linearScale.Strips.Add(strip)
' setup polar angle axis
m_AngularScale = 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
Dim valueAxis = polarChart.Axes(ENPolarAxis.PrimaryValue)
Dim gradScale As NAngularScale = New NAngularScale()
gradScale.AngleUnit = NUnit.Grad
gradScale.Labels.Style.Angle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0)
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim angleUnitComboBox As NComboBox = New NComboBox()
angleUnitComboBox.Items.Add("Degree")
angleUnitComboBox.Items.Add("Grad")
angleUnitComboBox.DropDownStyle = ENComboBoxStyle.DropDownList
angleUnitComboBox.SelectedIndexChanged += AddressOf OnAngleUnitComboBoxSelectedIndexChanged
angleUnitComboBox.SelectedIndex = 0
stack.Add(NPairBox.Create("Angle Unit:", angleUnitComboBox))
Dim minTickDistance As NNumericUpDown = New NNumericUpDown()
minTickDistance.Minimum = 10
minTickDistance.Maximum = 100
minTickDistance.ValueChanged += AddressOf OnMinTickDistanceValueChanged
minTickDistance.Value = 20
stack.Add(NPairBox.Create("Min Tick Distnace:", minTickDistance))
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create an angular scale.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Angular Scale", "https://www.nevron.com/docs/openvision/angular-scale.html"), ("Polar Axes", "https://www.nevron.com/docs/openvision/polar-chart-axes.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnMinTickDistanceValueChanged(arg As NValueChangeEventArgs)
m_AngularScale.MajorTickMode = ENMajorTickMode.AutoMinDistance
m_AngularScale.MinTickDistance = CDbl(arg.NewValue)
End Sub
Private Sub OnAngleUnitComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
Select Case arg.NewValue
Case 0
m_AngularScale.AngleUnit = NUnit.Degree
Case 1
m_AngularScale.AngleUnit = NUnit.Grad
End Select
End Sub
#End Region
#Region "Fields"
Private m_AngularScale As NAngularScale
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class