This example demonstrates how to create a chart with multiple area series and how to control the area depth category size.

| 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;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NMultiSeriesAreaExample";
// 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();
m_ChartView = chartViewWithCommandBars.View;
m_ChartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);
// configure title
m_ChartView.Surface.Titles[0].Text = "Multi Series Area";
// configure chart
NCartesianChart chart = (NCartesianChart)m_ChartView.Surface.Charts[0];
chart.Enable3D = true;
chart.ModelWidth = 100;
chart.ModelDepth = 80;
chart.ModelHeight = 40;
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted);
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight);
chart.Interactor = new NInteractor(new NTrackballTool());
// setup X axis
NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
scaleX.InflateContentRange = false;
// add interlaced stripe for Y axis
NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;
scaleY.Strips.Add(strip);
// add the first area
m_Area1 = new NAreaSeries();
m_Area1.Name = "Product A";
chart.Series.Add(m_Area1);
// add the second Area
m_Area2 = new NAreaSeries();
m_Area2.Name = "Product B";
chart.Series.Add(m_Area2);
// add the third Area
m_Area3 = new NAreaSeries();
m_Area3.Name = "Product C";
chart.Series.Add(m_Area3);
// fill with random data
Random random = new Random();
for (int i = 0; i < 10; i++)
{
m_Area1.DataPoints.Add(new NAreaDataPoint(random.Next(20, 50)));
m_Area2.DataPoints.Add(new NAreaDataPoint(random.Next(20, 50)));
m_Area3.DataPoints.Add(new NAreaDataPoint(random.Next(20, 50)));
}
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NHScrollBar areaDepthPercentScrollBar = new NHScrollBar();
areaDepthPercentScrollBar.Minimum = 0;
areaDepthPercentScrollBar.Maximum = 100;
areaDepthPercentScrollBar.ValueChanged += OnAreaDepthPercentScrollBarValueChanged;
areaDepthPercentScrollBar.Value = 80;
stack.Add(NPairBox.Create("Area Depth Percent: ", areaDepthPercentScrollBar));
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create a chart with multiple area series and how to control the area depth category size.
";
}
///
/// 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"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
private void OnAreaDepthPercentScrollBarValueChanged(NValueChangeEventArgs arg)
{
float depthPercent = (float)(double)arg.NewValue;
m_Area1.DepthPercent = depthPercent;
m_Area2.DepthPercent = depthPercent;
m_Area3.DepthPercent = depthPercent;
}
#endregion
#region Fields
private NChartView m_ChartView;
private NAreaSeries m_Area1;
private NAreaSeries m_Area2;
private NAreaSeries m_Area3;
#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.Chart.Tools
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 - NMultiSeriesAreaExample"
' 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()
m_ChartView = chartViewWithCommandBars.View
m_ChartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)
' configure title
m_ChartView.Surface.Titles(0).Text = "Multi Series Area"
' configure chart
Dim chart = CType(m_ChartView.Surface.Charts(0), NCartesianChart)
chart.Enable3D = True
chart.ModelWidth = 100
chart.ModelDepth = 80
chart.ModelHeight = 40
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted)
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight)
chart.Interactor = New NInteractor(New NTrackballTool())
' setup X axis
Dim scaleX As NOrdinalScale = chart.Axes(ENCartesianAxis.PrimaryX).Scale
scaleX.InflateContentRange = False
' add interlaced stripe for Y axis
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
Dim scaleY As NLinearScale = chart.Axes(ENCartesianAxis.PrimaryY).Scale
scaleY.Strips.Add(strip)
' add the first area
m_Area1 = New NAreaSeries()
m_Area1.Name = "Product A"
chart.Series.Add(m_Area1)
' add the second Area
m_Area2 = New NAreaSeries()
m_Area2.Name = "Product B"
chart.Series.Add(m_Area2)
' add the third Area
m_Area3 = New NAreaSeries()
m_Area3.Name = "Product C"
chart.Series.Add(m_Area3)
' fill with random data
Dim random As Random = New Random()
For i = 0 To 9
m_Area1.DataPoints.Add(New NAreaDataPoint(random.Next(20, 50)))
m_Area2.DataPoints.Add(New NAreaDataPoint(random.Next(20, 50)))
m_Area3.DataPoints.Add(New NAreaDataPoint(random.Next(20, 50)))
Next
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim areaDepthPercentScrollBar As NHScrollBar = New NHScrollBar()
areaDepthPercentScrollBar.Minimum = 0
areaDepthPercentScrollBar.Maximum = 100
areaDepthPercentScrollBar.ValueChanged += AddressOf OnAreaDepthPercentScrollBarValueChanged
areaDepthPercentScrollBar.Value = 80
stack.Add(NPairBox.Create("Area Depth Percent: ", areaDepthPercentScrollBar))
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a chart with multiple area series and how to control the area depth category size.
"
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")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnAreaDepthPercentScrollBarValueChanged(arg As NValueChangeEventArgs)
Dim depthPercent As Single = CDbl(arg.NewValue)
m_Area1.DepthPercent = depthPercent
m_Area2.DepthPercent = depthPercent
m_Area3.DepthPercent = depthPercent
End Sub
#End Region
#Region "Fields"
Private m_ChartView As NChartView
Private m_Area1 As NAreaSeries
Private m_Area2 As NAreaSeries
Private m_Area3 As NAreaSeries
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class