This example demonstrates how to create a standard 3D bar 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 - NStandard3DBarExample";
// 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);
// Set the title
chartView.Surface.Titles[0].Text = "Standard 3D Bar";
// Configure the chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
chart.Enable3D = true;
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.YLinearXZOrdinal);
chart.Axes[ENCartesianAxis.Depth].Visible = true;
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective1);
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft);
chart.Interactor = new NInteractor(new NTrackballTool());
// Add an interlace stripe
NLinearScale linearScale = chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// Setup a bar series
m_Bar = new NBarSeries();
m_Bar.Name = "Bar Series";
m_Bar.InflateMargins = true;
m_Bar.UseXValues = false;
// Add some data to the bar series
m_Bar.LegendView.Mode = ENSeriesLegendMode.DataPoints;
m_Bar.DataPoints.Add(new NBarDataPoint(18, "C++"));
m_Bar.DataPoints.Add(new NBarDataPoint(15, "Ruby"));
m_Bar.DataPoints.Add(new NBarDataPoint(21, "Python"));
m_Bar.DataPoints.Add(new NBarDataPoint(23, "Java"));
m_Bar.DataPoints.Add(new NBarDataPoint(27, "JavaScript"));
m_Bar.DataPoints.Add(new NBarDataPoint(29, "C#"));
m_Bar.DataPoints.Add(new NBarDataPoint(26, "PHP"));
chart.Series.Add(m_Bar);
// Configure the X axis to show the language names
string[] labels = new string[m_Bar.DataPoints.Count];
for (int i = 0; i < m_Bar.DataPoints.Count; i++)
{
labels[i] = m_Bar.DataPoints[i].Label;
}
NOrdinalScale xAxisScale = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
xAxisScale.Labels.TextProvider = new NOrdinalScaleLabelTextProvider(labels);
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();
customOriginUpDown.ValueChanged += OnCustomOriginUpDownValueChanged;
stack.Add(NPairBox.Create("Custom Origin: ", customOriginUpDown));
}
{
NComboBox barShapeCompboBox = new NComboBox();
barShapeCompboBox.Items.FillFromEnum();
barShapeCompboBox.SelectedIndexChanged += OnBarShapeComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Bar Shape: ", barShapeCompboBox));
}
{
NHScrollBar widthPercentScrollbar = new NHScrollBar();
widthPercentScrollbar.Minimum = 0;
widthPercentScrollbar.Maximum = 100;
widthPercentScrollbar.ValueChanged += OnWidthPercentScrollbarValueChanged;
widthPercentScrollbar.Value = 20;
stack.Add(NPairBox.Create("Width Gap %: ", widthPercentScrollbar));
}
{
NHScrollBar depthPercentScrollbar = new NHScrollBar();
depthPercentScrollbar.Minimum = 0;
depthPercentScrollbar.Maximum = 100;
depthPercentScrollbar.ValueChanged += OnDepthPercentScrollbarValueChanged;
depthPercentScrollbar.Value = 20;
stack.Add(NPairBox.Create("Depth Gap %: ", depthPercentScrollbar));
}
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create a standard 3D bar chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Bar Series", "https://www.nevron.com/docs/openvision/bar-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_Bar.CustomOrigin = (double)((NNumericUpDown)arg.TargetNode).Value;
}
void OnOriginModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Bar.OriginMode = (ENSeriesOriginMode)((NComboBox)arg.TargetNode).SelectedIndex;
}
void OnBarShapeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Bar.Shape = (ENBarShape)((NComboBox)arg.TargetNode).SelectedIndex;
}
private void OnWidthPercentScrollbarValueChanged(NValueChangeEventArgs arg)
{
m_Bar.WidthGapFactor = ((NHScrollBar)arg.TargetNode).Value / 100;
}
private void OnDepthPercentScrollbarValueChanged(NValueChangeEventArgs arg)
{
m_Bar.DepthGapFactor = ((NHScrollBar)arg.TargetNode).Value / 100;
}
#endregion
#region Fields
NBarSeries m_Bar;
#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.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 - NStandard3DBarExample"
' 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)
' Set the title
chartView.Surface.Titles(0).Text = "Standard 3D Bar"
' Configure the chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
chart.Enable3D = True
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.YLinearXZOrdinal)
chart.Axes(ENCartesianAxis.Depth).Visible = True
chart.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective1)
chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft)
chart.Interactor = New NInteractor(New NTrackballTool())
' Add an interlace stripe
Dim linearScale As NLinearScale = TryCast(chart.Axes(ENCartesianAxis.PrimaryY).Scale, NLinearScale)
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(ENNamedColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
linearScale.Strips.Add(strip)
' Setup a bar series
m_Bar = New NBarSeries()
m_Bar.Name = "Bar Series"
m_Bar.InflateMargins = True
m_Bar.UseXValues = False
' Add some data to the bar series
m_Bar.LegendView.Mode = ENSeriesLegendMode.DataPoints
m_Bar.DataPoints.Add(New NBarDataPoint(18, "C++"))
m_Bar.DataPoints.Add(New NBarDataPoint(15, "Ruby"))
m_Bar.DataPoints.Add(New NBarDataPoint(21, "Python"))
m_Bar.DataPoints.Add(New NBarDataPoint(23, "Java"))
m_Bar.DataPoints.Add(New NBarDataPoint(27, "JavaScript"))
m_Bar.DataPoints.Add(New NBarDataPoint(29, "C#"))
m_Bar.DataPoints.Add(New NBarDataPoint(26, "PHP"))
chart.Series.Add(m_Bar)
' Configure the X axis to show the language names
Dim labels = New String(m_Bar.DataPoints.Count - 1) {}
For i = 0 To m_Bar.DataPoints.Count - 1
labels(i) = m_Bar.DataPoints(i).Label
Next
Dim xAxisScale As NOrdinalScale = chart.Axes(ENCartesianAxis.PrimaryX).Scale
xAxisScale.Labels.TextProvider = New NOrdinalScaleLabelTextProvider(labels)
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
If True Then
Dim originModeComboBox As NComboBox = New NComboBox()
originModeComboBox.Items.FillFromEnum(Of ENSeriesOriginMode)()
originModeComboBox.SelectedIndexChanged += AddressOf OnOriginModeComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Origin Mode: ", originModeComboBox))
End If
If True Then
Dim customOriginUpDown As NNumericUpDown = New NNumericUpDown()
customOriginUpDown.ValueChanged += AddressOf OnCustomOriginUpDownValueChanged
stack.Add(NPairBox.Create("Custom Origin: ", customOriginUpDown))
End If
If True Then
Dim barShapeCompboBox As NComboBox = New NComboBox()
barShapeCompboBox.Items.FillFromEnum(Of ENBarShape)()
barShapeCompboBox.SelectedIndexChanged += AddressOf OnBarShapeComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Bar Shape: ", barShapeCompboBox))
End If
If True Then
Dim widthPercentScrollbar As NHScrollBar = New NHScrollBar()
widthPercentScrollbar.Minimum = 0
widthPercentScrollbar.Maximum = 100
widthPercentScrollbar.ValueChanged += AddressOf OnWidthPercentScrollbarValueChanged
widthPercentScrollbar.Value = 20
stack.Add(NPairBox.Create("Width Gap %: ", widthPercentScrollbar))
End If
If True Then
Dim depthPercentScrollbar As NHScrollBar = New NHScrollBar()
depthPercentScrollbar.Minimum = 0
depthPercentScrollbar.Maximum = 100
depthPercentScrollbar.ValueChanged += AddressOf OnDepthPercentScrollbarValueChanged
depthPercentScrollbar.Value = 20
stack.Add(NPairBox.Create("Depth Gap %: ", depthPercentScrollbar))
End If
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a standard 3D bar chart.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Bar Series", "https://www.nevron.com/docs/openvision/bar-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_Bar.CustomOrigin = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnOriginModeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_Bar.OriginMode = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENSeriesOriginMode)
End Sub
Private Sub OnBarShapeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_Bar.Shape = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENBarShape)
End Sub
Private Sub OnWidthPercentScrollbarValueChanged(arg As NValueChangeEventArgs)
m_Bar.WidthGapFactor = CType(arg.TargetNode, NHScrollBar).Value / 100
End Sub
Private Sub OnDepthPercentScrollbarValueChanged(arg As NValueChangeEventArgs)
m_Bar.DepthGapFactor = CType(arg.TargetNode, NHScrollBar).Value / 100
End Sub
#End Region
#Region "Fields"
Private m_Bar As NBarSeries
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class