This example demonstrates how to configure axis strips.

| 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 - NAxisStripsExample";
// 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);
chartView.Surface.Titles[0].Text = "Axis Strips";
// configure chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
// configure axes
NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;
// add interlaced stripe
m_Strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
m_Strip.Interlaced = true;
scaleY.Strips.Add(m_Strip);
// enable the major y grid lines
scaleY.MajorGridLines = new NScaleGridLines();
NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
// enable the major x grid lines
scaleX.MajorGridLines = new NScaleGridLines();
// create dummy data
NBarSeries bar = new NBarSeries();
bar.Name = "Bars";
bar.DataLabelStyle = new NDataLabelStyle(false);
Random random = new Random();
for (int i = 0; i < 10; i++)
{
bar.DataPoints.Add(new NBarDataPoint(random.Next(100)));
}
chart.Series.Add(bar);
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
stack.Add(new NLabel("Y Axis Grid"));
NNumericUpDown beginUpDown = new NNumericUpDown();
beginUpDown.ValueChanged += OnBeginUpDownValueChanged;
stack.Add(NPairBox.Create("Begin:", beginUpDown));
beginUpDown.Value = 0;
NNumericUpDown endUpDown = new NNumericUpDown();
endUpDown.ValueChanged += OnEndUpDownValueChanged;
stack.Add(NPairBox.Create("End:", endUpDown));
endUpDown.Value = 0;
NCheckBox infiniteCheckBox = new NCheckBox("Infinite");
infiniteCheckBox.CheckedChanged += OnInfiniteCheckBoxCheckedChanged;
stack.Add(infiniteCheckBox);
infiniteCheckBox.Checked = true;
NNumericUpDown lengthUpDown = new NNumericUpDown();
lengthUpDown.ValueChanged += OnLengthUpDownValueChanged;
stack.Add(NPairBox.Create("Length:", lengthUpDown));
lengthUpDown.Value = 1;
NNumericUpDown intervalUpDown = new NNumericUpDown();
intervalUpDown.ValueChanged += OnIntervalUpDownValueChanged;
stack.Add(NPairBox.Create("Interval:", intervalUpDown));
intervalUpDown.Value = 1;
NColorBox colorBox = new NColorBox();
colorBox.SelectedColorChanged += OnColorBoxSelectedColorChanged;
stack.Add(NPairBox.Create("Color:", colorBox));
colorBox.SelectedColor = NColor.Beige;
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to configure axis strips.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Common Axis Functionality", "https://www.nevron.com/docs/openvision/chart-common-axis-functionality.html"),
("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"),
("Fill", "https://www.nevron.com/docs/openvision/graphics-fill.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
void OnIntervalUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Strip.Interval = (int)((NNumericUpDown)arg.TargetNode).Value;
}
void OnLengthUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Strip.Length = (int)((NNumericUpDown)arg.TargetNode).Value;
}
void OnColorBoxSelectedColorChanged(NValueChangeEventArgs arg)
{
m_Strip.Fill = new NColorFill(((NColorBox)arg.TargetNode).SelectedColor);
}
void OnInfiniteCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_Strip.Infinite = ((NCheckBox)arg.TargetNode).Checked;
}
void OnEndUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Strip.End = (int)((NNumericUpDown)arg.TargetNode).Value;
}
void OnBeginUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Strip.Begin = (int)((NNumericUpDown)arg.TargetNode).Value;
}
#endregion
#region Fields
NScaleStrip m_Strip;
#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.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 - NAxisStripsExample"
' 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()
Dim chartView = chartViewWithCommandBars.View
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)
chartView.Surface.Titles(0).Text = "Axis Strips"
' configure chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
' configure axes
Dim scaleY As NLinearScale = chart.Axes(ENCartesianAxis.PrimaryY).Scale
' add interlaced stripe
m_Strip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
m_Strip.Interlaced = True
scaleY.Strips.Add(m_Strip)
' enable the major y grid lines
scaleY.MajorGridLines = New NScaleGridLines()
Dim scaleX As NOrdinalScale = chart.Axes(ENCartesianAxis.PrimaryX).Scale
' enable the major x grid lines
scaleX.MajorGridLines = New NScaleGridLines()
' create dummy data
Dim bar As NBarSeries = New NBarSeries()
bar.Name = "Bars"
bar.DataLabelStyle = New NDataLabelStyle(False)
Dim random As Random = New Random()
For i = 0 To 9
bar.DataPoints.Add(New NBarDataPoint(random.Next(100)))
Next
chart.Series.Add(bar)
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 boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
stack.Add(New NLabel("Y Axis Grid"))
Dim beginUpDown As NNumericUpDown = New NNumericUpDown()
beginUpDown.ValueChanged += AddressOf OnBeginUpDownValueChanged
stack.Add(NPairBox.Create("Begin:", beginUpDown))
beginUpDown.Value = 0
Dim endUpDown As NNumericUpDown = New NNumericUpDown()
endUpDown.ValueChanged += AddressOf OnEndUpDownValueChanged
stack.Add(NPairBox.Create("End:", endUpDown))
endUpDown.Value = 0
Dim infiniteCheckBox As NCheckBox = New NCheckBox("Infinite")
infiniteCheckBox.CheckedChanged += AddressOf OnInfiniteCheckBoxCheckedChanged
stack.Add(infiniteCheckBox)
infiniteCheckBox.Checked = True
Dim lengthUpDown As NNumericUpDown = New NNumericUpDown()
lengthUpDown.ValueChanged += AddressOf OnLengthUpDownValueChanged
stack.Add(NPairBox.Create("Length:", lengthUpDown))
lengthUpDown.Value = 1
Dim intervalUpDown As NNumericUpDown = New NNumericUpDown()
intervalUpDown.ValueChanged += AddressOf OnIntervalUpDownValueChanged
stack.Add(NPairBox.Create("Interval:", intervalUpDown))
intervalUpDown.Value = 1
Dim colorBox As NColorBox = New NColorBox()
colorBox.SelectedColorChanged += AddressOf OnColorBoxSelectedColorChanged
stack.Add(NPairBox.Create("Color:", colorBox))
colorBox.SelectedColor = NColor.Beige
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to configure axis strips.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Common Axis Functionality", "https://www.nevron.com/docs/openvision/chart-common-axis-functionality.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"), ("Fill", "https://www.nevron.com/docs/openvision/graphics-fill.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnIntervalUpDownValueChanged(arg As NValueChangeEventArgs)
m_Strip.Interval = CInt(CType(arg.TargetNode, NNumericUpDown).Value)
End Sub
Private Sub OnLengthUpDownValueChanged(arg As NValueChangeEventArgs)
m_Strip.Length = CInt(CType(arg.TargetNode, NNumericUpDown).Value)
End Sub
Private Sub OnColorBoxSelectedColorChanged(arg As NValueChangeEventArgs)
m_Strip.Fill = New NColorFill(CType(arg.TargetNode, NColorBox).SelectedColor)
End Sub
Private Sub OnInfiniteCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_Strip.Infinite = CType(arg.TargetNode, NCheckBox).Checked
End Sub
Private Sub OnEndUpDownValueChanged(arg As NValueChangeEventArgs)
m_Strip.End = CInt(CType(arg.TargetNode, NNumericUpDown).Value)
End Sub
Private Sub OnBeginUpDownValueChanged(arg As NValueChangeEventArgs)
m_Strip.Begin = CInt(CType(arg.TargetNode, NNumericUpDown).Value)
End Sub
#End Region
#Region "Fields"
Private m_Strip As NScaleStrip
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class