This example demonstrates the functionality of the error bar series.

| 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 - NStandardErrorBarExample";
// 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 Error Bar";
// configure chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);
// add interlace stripe
NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
stripStyle.Interlaced = true;
chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(stripStyle);
chart.Axes[ENCartesianAxis.PrimaryY].Scale.MajorGridLines.Visible = true;
chart.Axes[ENCartesianAxis.PrimaryY].Scale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
chart.Axes[ENCartesianAxis.PrimaryY].Scale.InflateViewRangeBegin = true;
chart.Axes[ENCartesianAxis.PrimaryY].Scale.InflateViewRangeEnd = true;
chart.Axes[ENCartesianAxis.PrimaryX].Scale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
chart.Axes[ENCartesianAxis.PrimaryX].Scale.InflateViewRangeBegin = true;
chart.Axes[ENCartesianAxis.PrimaryX].Scale.InflateViewRangeEnd = true;
// add an error bar series
m_ErrorBar = new NErrorBarSeries();
chart.Series.Add(m_ErrorBar);
m_ErrorBar.DataLabelStyle = new NDataLabelStyle(false);
m_ErrorBar.Stroke = new NStroke(NColor.Black);
m_ErrorBar.UseXValues = true;
GenerateData();
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
NCheckBox inflateMarginsCheckBox = new NCheckBox("Inflate Margins");
inflateMarginsCheckBox.CheckedChanged += OnInflateMarginsCheckBoxCheckedChanged;
inflateMarginsCheckBox.Checked = true;
stack.Add(inflateMarginsCheckBox);
NCheckBox showUpperXErrorCheckBox = new NCheckBox("Show Upper X Error");
showUpperXErrorCheckBox.CheckedChanged += OnShowUpperXErrorCheckBoxCheckedChanged;
showUpperXErrorCheckBox.Checked = true;
stack.Add(showUpperXErrorCheckBox);
NCheckBox showLowerXErrorCheckBox = new NCheckBox("Show Lower X Error");
showLowerXErrorCheckBox.CheckedChanged += OnShowLowerXErrorCheckBoxCheckedChanged;
showLowerXErrorCheckBox.Checked = true;
stack.Add(showLowerXErrorCheckBox);
NNumericUpDown xErrorSizeUpDown = new NNumericUpDown();
xErrorSizeUpDown.Value = m_ErrorBar.XErrorSize;
xErrorSizeUpDown.ValueChanged += OnXErrorSizeUpDownValueChanged;
stack.Add(NPairBox.Create("X Error Size:", xErrorSizeUpDown));
NCheckBox showUpperYErrorCheckBox = new NCheckBox("Show Upper Y Error");
showUpperYErrorCheckBox.CheckedChanged += OnShowUpperYErrorCheckBoxCheckedChanged;
showUpperYErrorCheckBox.Checked = true;
stack.Add(showUpperYErrorCheckBox);
NCheckBox showLowerYErrorCheckBox = new NCheckBox("Show Lower Y Error");
showLowerYErrorCheckBox.CheckedChanged += OnShowLowerYErrorCheckBoxCheckedChanged;
showLowerYErrorCheckBox.Checked = true;
stack.Add(showLowerYErrorCheckBox);
NNumericUpDown yErrorSizeUpDown = new NNumericUpDown();
yErrorSizeUpDown.Value = m_ErrorBar.YErrorSize;
yErrorSizeUpDown.ValueChanged +=OnYErrorSizeUpDownValueChanged;
stack.Add(NPairBox.Create("X Error Size:", yErrorSizeUpDown));
return group;
}
public string GetExampleDescription()
{
return @"This example demonstrates the functionality of the error bar series.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Error Bar Series", "https://www.nevron.com/docs/openvision/error-bar-chart-series.html"),
("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"),
};
}
#endregion
#region Implementation
private void GenerateData()
{
m_ErrorBar.DataPoints.Clear();
double y;
double x = 50.0;
Random random = new Random();
for (int i = 0; i < 15; i++)
{
y = 20 + random.NextDouble() * 30;
x += 2.0 + random.NextDouble() * 2;
double lowerYError = 1 + random.NextDouble();
double upperYError = 1 + random.NextDouble();
double lowerXError = 1 + random.NextDouble();
double upperXError = 1 + random.NextDouble();
m_ErrorBar.DataPoints.Add(new NErrorBarDataPoint(x, y, upperXError, lowerXError, upperYError, lowerYError));
}
}
#endregion
#region Event Handlers
void OnInflateMarginsCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.InflateMargins = ((NCheckBox)arg.TargetNode).Checked;
}
void OnYErrorSizeUpDownValueChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.YErrorSize = ((NNumericUpDown)arg.TargetNode).Value;
}
void OnXErrorSizeUpDownValueChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.XErrorSize = ((NNumericUpDown)arg.TargetNode).Value;
}
void OnShowLowerYErrorCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.ShowLowerYError = ((NCheckBox)arg.TargetNode).Checked;
}
void OnShowUpperYErrorCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.ShowUpperYError = ((NCheckBox)arg.TargetNode).Checked;
}
void OnShowLowerXErrorCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.ShowLowerXError = ((NCheckBox)arg.TargetNode).Checked;
}
void OnShowUpperXErrorCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_ErrorBar.ShowUpperXError = ((NCheckBox)arg.TargetNode).Checked;
}
#endregion
#region Fields
NErrorBarSeries m_ErrorBar;
#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 - NStandardErrorBarExample"
' 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 Error Bar"
' configure chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear)
' add interlace stripe
Dim stripStyle As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
stripStyle.Interlaced = True
chart.Axes(ENCartesianAxis.PrimaryY).Scale.Strips.Add(stripStyle)
chart.Axes(ENCartesianAxis.PrimaryY).Scale.MajorGridLines.Visible = True
chart.Axes(ENCartesianAxis.PrimaryY).Scale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick
chart.Axes(ENCartesianAxis.PrimaryY).Scale.InflateViewRangeBegin = True
chart.Axes(ENCartesianAxis.PrimaryY).Scale.InflateViewRangeEnd = True
chart.Axes(ENCartesianAxis.PrimaryX).Scale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick
chart.Axes(ENCartesianAxis.PrimaryX).Scale.InflateViewRangeBegin = True
chart.Axes(ENCartesianAxis.PrimaryX).Scale.InflateViewRangeEnd = True
' add an error bar series
m_ErrorBar = New NErrorBarSeries()
chart.Series.Add(m_ErrorBar)
m_ErrorBar.DataLabelStyle = New NDataLabelStyle(False)
m_ErrorBar.Stroke = New NStroke(NColor.Black)
m_ErrorBar.UseXValues = True
GenerateData()
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)
Dim inflateMarginsCheckBox As NCheckBox = New NCheckBox("Inflate Margins")
inflateMarginsCheckBox.CheckedChanged += AddressOf OnInflateMarginsCheckBoxCheckedChanged
inflateMarginsCheckBox.Checked = True
stack.Add(inflateMarginsCheckBox)
Dim showUpperXErrorCheckBox As NCheckBox = New NCheckBox("Show Upper X Error")
showUpperXErrorCheckBox.CheckedChanged += AddressOf OnShowUpperXErrorCheckBoxCheckedChanged
showUpperXErrorCheckBox.Checked = True
stack.Add(showUpperXErrorCheckBox)
Dim showLowerXErrorCheckBox As NCheckBox = New NCheckBox("Show Lower X Error")
showLowerXErrorCheckBox.CheckedChanged += AddressOf OnShowLowerXErrorCheckBoxCheckedChanged
showLowerXErrorCheckBox.Checked = True
stack.Add(showLowerXErrorCheckBox)
Dim xErrorSizeUpDown As NNumericUpDown = New NNumericUpDown()
xErrorSizeUpDown.Value = m_ErrorBar.XErrorSize
xErrorSizeUpDown.ValueChanged += AddressOf OnXErrorSizeUpDownValueChanged
stack.Add(NPairBox.Create("X Error Size:", xErrorSizeUpDown))
Dim showUpperYErrorCheckBox As NCheckBox = New NCheckBox("Show Upper Y Error")
showUpperYErrorCheckBox.CheckedChanged += AddressOf OnShowUpperYErrorCheckBoxCheckedChanged
showUpperYErrorCheckBox.Checked = True
stack.Add(showUpperYErrorCheckBox)
Dim showLowerYErrorCheckBox As NCheckBox = New NCheckBox("Show Lower Y Error")
showLowerYErrorCheckBox.CheckedChanged += AddressOf OnShowLowerYErrorCheckBoxCheckedChanged
showLowerYErrorCheckBox.Checked = True
stack.Add(showLowerYErrorCheckBox)
Dim yErrorSizeUpDown As NNumericUpDown = New NNumericUpDown()
yErrorSizeUpDown.Value = m_ErrorBar.YErrorSize
yErrorSizeUpDown.ValueChanged += AddressOf OnYErrorSizeUpDownValueChanged
stack.Add(NPairBox.Create("X Error Size:", yErrorSizeUpDown))
Return group
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates the functionality of the error bar series.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Error Bar Series", "https://www.nevron.com/docs/openvision/error-bar-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html")}
End Function
#End Region
#Region "Implementation"
Private Sub GenerateData()
m_ErrorBar.DataPoints.Clear()
Dim y As Double
Dim x = 50.0
Dim random As Random = New Random()
For i = 0 To 14
y = 20 + random.NextDouble() * 30
x += 2.0 + random.NextDouble() * 2
Dim lowerYError As Double = 1 + random.NextDouble()
Dim upperYError As Double = 1 + random.NextDouble()
Dim lowerXError As Double = 1 + random.NextDouble()
Dim upperXError As Double = 1 + random.NextDouble()
m_ErrorBar.DataPoints.Add(New NErrorBarDataPoint(x, y, upperXError, lowerXError, upperYError, lowerYError))
Next
End Sub
#End Region
#Region "Event Handlers"
Private Sub OnInflateMarginsCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_ErrorBar.InflateMargins = CType(arg.TargetNode, NCheckBox).Checked
End Sub
Private Sub OnYErrorSizeUpDownValueChanged(arg As NValueChangeEventArgs)
m_ErrorBar.YErrorSize = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnXErrorSizeUpDownValueChanged(arg As NValueChangeEventArgs)
m_ErrorBar.XErrorSize = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnShowLowerYErrorCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_ErrorBar.ShowLowerYError = CType(arg.TargetNode, NCheckBox).Checked
End Sub
Private Sub OnShowUpperYErrorCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_ErrorBar.ShowUpperYError = CType(arg.TargetNode, NCheckBox).Checked
End Sub
Private Sub OnShowLowerXErrorCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_ErrorBar.ShowLowerXError = CType(arg.TargetNode, NCheckBox).Checked
End Sub
Private Sub OnShowUpperXErrorCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_ErrorBar.ShowUpperXError = CType(arg.TargetNode, NCheckBox).Checked
End Sub
#End Region
#Region "Fields"
Private m_ErrorBar As NErrorBarSeries
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class