This example demonstrates how to create a standard 3D area chart.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Chart.Tools;
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 - NStandard3DAreaExample";
// 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.Cartesian);
// configure title
chartView.Surface.Titles[0].Text = "Standard Area";
// configure chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart = chart;
chart.Enable3D = true;
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight);
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted);
chart.Projection.ModelFitMode = Nov.Graphics.ENProjectionModelFitMode.Sphere;
chart.Interactor = new NInteractor(new NTrackballTool());
// setup X axis
NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
scaleX.InflateContentRange = false;
scaleX.MajorTickMode = ENMajorTickMode.AutoMaxCount;
scaleX.DisplayDataPointsBetweenTicks = false;
scaleX.Labels.Visible = false;
for (int i = 0; i < monthLetters.Length; i++)
{
scaleX.CustomLabels.Add(new NCustomValueLabel(i, monthLetters[i]));
}
// add interlaced stripe for Y axis
NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
stripStyle.Interlaced = true;
NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;
scaleY.Strips.Add(stripStyle);
// setup area series
m_Area = new NAreaSeries();
m_Area.Name = "Area Series";
NDataLabelStyle dataLabelStyle = new NDataLabelStyle();
dataLabelStyle.Visible = true;
dataLabelStyle.Format = "";
m_Area.DataLabelStyle = dataLabelStyle;
for (int i = 0; i < monthValues.Length; i++)
{
m_Area.DataPoints.Add(new NAreaDataPoint(monthValues[i]));
}
chart.Series.Add(m_Area);
return chartViewWithCommandBars;
}
///
///
///
///
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NComboBox originModeComboBox = new NComboBox();
originModeComboBox.Items.FillFromEnum();
originModeComboBox.SelectedIndexChanged += OnOriginModeComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Origin Mode: ", originModeComboBox));
NNumericUpDown customOriginUpDown = new NNumericUpDown();
m_CustomOriginUpDown = customOriginUpDown;
m_CustomOriginUpDown.Enabled = m_Area.OriginMode == ENSeriesOriginMode.CustomOrigin;
customOriginUpDown.ValueChanged += OnCustomOriginUpDownValueChanged;
customOriginUpDown.Value = 17;
stack.Add(NPairBox.Create("Custom Origin: ", customOriginUpDown));
NNumericUpDown depthPercentUpDown = new NNumericUpDown();
depthPercentUpDown.ValueChanged += OnDepthPercentUpDownValueChanged;
depthPercentUpDown.Value = 50.0f;
stack.Add(NPairBox.Create("Depth Percent: ", depthPercentUpDown));
NComboBox boundsModeComboBox = new NComboBox();
boundsModeComboBox.Items.FillFromEnum();
boundsModeComboBox.SelectedIndexChanged += BoundsModeComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Model Fit Mode: ", boundsModeComboBox));
return boxGroup;
}
///
///
///
///
public string GetExampleDescription()
{
return @"This example demonstrates how to create a standard 3D area chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Area Series", "https://www.nevron.com/docs/openvision/area-chart-series.html"),
("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"),
("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"),
("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
void OnCustomOriginUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Area.CustomOrigin = (double)((NNumericUpDown)arg.TargetNode).Value;
}
void OnOriginModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Area.OriginMode = (ENSeriesOriginMode)((NComboBox)arg.TargetNode).SelectedIndex;
m_CustomOriginUpDown.Enabled = m_Area.OriginMode == ENSeriesOriginMode.CustomOrigin;
}
private void OnDepthPercentUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Area.DepthPercent = (float)((NNumericUpDown)arg.TargetNode).Value;
}
private void BoundsModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Chart.Projection.ModelFitMode = (ENProjectionModelFitMode)arg.NewValue;
}
#endregion
#region Fields
NAreaSeries m_Area;
NCartesianChart m_Chart;
NNumericUpDown m_CustomOriginUpDown;
#endregion
#region Static Methods
#endregion
#region Constants
internal static readonly double[] monthValues = new double[] { 16, 19, 16, 15, 18, 19, 24, 21, 22, 17, 19, 15 };
internal static readonly string[] monthLetters = new string[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" };
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Chart.Tools
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 - NStandard3DAreaExample"
' 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.Cartesian)
' configure title
chartView.Surface.Titles(0).Text = "Standard Area"
' configure chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart = chart
chart.Enable3D = True
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight)
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted)
chart.Projection.ModelFitMode = ENProjectionModelFitMode.Sphere
chart.Interactor = New NInteractor(New NTrackballTool())
' setup X axis
Dim scaleX As NOrdinalScale = chart.Axes(ENCartesianAxis.PrimaryX).Scale
scaleX.InflateContentRange = False
scaleX.MajorTickMode = ENMajorTickMode.AutoMaxCount
scaleX.DisplayDataPointsBetweenTicks = False
scaleX.Labels.Visible = False
For i = 0 To monthLetters.Length - 1
scaleX.CustomLabels.Add(New NCustomValueLabel(i, monthLetters(i)))
Next
' add interlaced stripe for Y axis
Dim stripStyle As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
stripStyle.Interlaced = True
Dim scaleY As NLinearScale = chart.Axes(ENCartesianAxis.PrimaryY).Scale
scaleY.Strips.Add(stripStyle)
' setup area series
m_Area = New NAreaSeries()
m_Area.Name = "Area Series"
Dim dataLabelStyle As NDataLabelStyle = New NDataLabelStyle()
dataLabelStyle.Visible = True
dataLabelStyle.Format = ""
m_Area.DataLabelStyle = dataLabelStyle
For i = 0 To monthValues.Length - 1
m_Area.DataPoints.Add(New NAreaDataPoint(monthValues(i)))
Next
chart.Series.Add(m_Area)
Return chartViewWithCommandBars
End Function
'''
'''
'''
'''
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim originModeComboBox As NComboBox = New NComboBox()
originModeComboBox.Items.FillFromEnum(Of ENSeriesOriginMode)()
originModeComboBox.SelectedIndexChanged += AddressOf OnOriginModeComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Origin Mode: ", originModeComboBox))
Dim customOriginUpDown As NNumericUpDown = New NNumericUpDown()
m_CustomOriginUpDown = customOriginUpDown
m_CustomOriginUpDown.Enabled = m_Area.OriginMode Is ENSeriesOriginMode.CustomOrigin
customOriginUpDown.ValueChanged += AddressOf OnCustomOriginUpDownValueChanged
customOriginUpDown.Value = 17
stack.Add(NPairBox.Create("Custom Origin: ", customOriginUpDown))
Dim depthPercentUpDown As NNumericUpDown = New NNumericUpDown()
depthPercentUpDown.ValueChanged += AddressOf OnDepthPercentUpDownValueChanged
depthPercentUpDown.Value = 50.0F
stack.Add(NPairBox.Create("Depth Percent: ", depthPercentUpDown))
Dim boundsModeComboBox As NComboBox = New NComboBox()
boundsModeComboBox.Items.FillFromEnum(Of ENProjectionModelFitMode)()
boundsModeComboBox.SelectedIndexChanged += AddressOf BoundsModeComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Model Fit Mode: ", boundsModeComboBox))
Return boxGroup
End Function
'''
'''
'''
'''
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a standard 3D area chart.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Area Series", "https://www.nevron.com/docs/openvision/area-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnCustomOriginUpDownValueChanged(arg As NValueChangeEventArgs)
m_Area.CustomOrigin = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnOriginModeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_Area.OriginMode = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENSeriesOriginMode)
m_CustomOriginUpDown.Enabled = m_Area.OriginMode Is ENSeriesOriginMode.CustomOrigin
End Sub
Private Sub OnDepthPercentUpDownValueChanged(arg As NValueChangeEventArgs)
m_Area.DepthPercent = CSng(CType(arg.TargetNode, NNumericUpDown).Value)
End Sub
Private Sub BoundsModeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_Chart.Projection.ModelFitMode = CType(arg.NewValue, ENProjectionModelFitMode)
End Sub
#End Region
#Region "Fields"
Private m_Area As NAreaSeries
Private m_Chart As NCartesianChart
Private m_CustomOriginUpDown As NNumericUpDown
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
Friend Shared ReadOnly monthValues As Double() = New Double() {16, 19, 16, 15, 18, 19, 24, 21, 22, 17, 19, 15}
Friend Shared ReadOnly monthLetters As String() = New String() {"J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}
#End Region
#Region "Nested Types"
#End Region
End Class