This example demonstrates how to create a polar vector 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.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NPolarVectorExample";
// 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 Vector";
// 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.Visible = true;
NScaleStrip strip = new NScaleStrip();
strip.Fill = new NColorFill(new NColor(NColor.Beige, 125));
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// create a polar line series
NPolarVectorSeries vectorSeries = new NPolarVectorSeries();
m_Chart.Series.Add(vectorSeries);
vectorSeries.Name = "Series 1";
vectorSeries.DataLabelStyle = new NDataLabelStyle(false);
for (int i = 0; i < 360; i += 30)
{
for (int j = 10; j <= 100; j += 10)
{
vectorSeries.DataPoints.Add(new NPolarVectorDataPoint(i, j, i + j / 10, j, null, new NStroke(1, ColorFromValue(j))));
}
}
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 vector chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Polar Vector Series", "https://www.nevron.com/docs/openvision/polar-vector-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
#endregion
#region Event Handlers
#endregion
#region Fields
NPolarChart m_Chart;
#endregion
#region Static Methods
private static NColor ColorFromValue(double value)
{
return NColor.InterpolateColors(NColor.Red, NColor.Blue, value / 100.0);
}
#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
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 - NPolarVectorExample"
' 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 = "Polar Vector"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NPolarChart)
m_Chart.SetPredefinedPolarAxes(ENPredefinedPolarAxes.AngleValue)
' 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
Dim strip As NScaleStrip = New NScaleStrip()
strip.Fill = New NColorFill(New NColor(NColor.Beige, 125))
strip.Interlaced = True
linearScale.Strips.Add(strip)
' create a polar line series
Dim vectorSeries As NPolarVectorSeries = New NPolarVectorSeries()
m_Chart.Series.Add(vectorSeries)
vectorSeries.Name = "Series 1"
vectorSeries.DataLabelStyle = New NDataLabelStyle(False)
For i = 0 To 359 Step 30
For j = 10 To 100 Step 10
vectorSeries.DataPoints.Add(New NPolarVectorDataPoint(i, j, i + j / 10, j, Nothing, New NStroke(1, ColorFromValue(j))))
Next
Next
chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series))
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Return group
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a polar vector chart.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Polar Vector Series", "https://www.nevron.com/docs/openvision/polar-vector-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")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_Chart As NPolarChart
#End Region
#Region "Static Methods"
Private Shared Function ColorFromValue(value As Double) As NColor
Return NColor.InterpolateColors(NColor.Red, NColor.Blue, value / 100.0)
End Function
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class