This example demonstrates how to change the appearance of scale breaks.

| 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 - NScaleBreakAppearanceExample";
// 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 = "Scale Breaks Appearance";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart.Padding = new NMargins(20);
// configure axes
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
// configure scale
NLinearScale yScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;
yScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
m_ScaleBreak = new NAutoScaleBreak(0.4f);
m_ScaleBreak.PositionMode = ENScaleBreakPositionMode.Percent;
yScale.ScaleBreaks.Add(m_ScaleBreak);
// add an interlaced strip to the Y axis
NScaleStrip interlacedStrip = new NScaleStrip();
interlacedStrip.Interlaced = true;
interlacedStrip.Fill = new NColorFill(NColor.Beige);
yScale.Strips.Add(interlacedStrip);
// Create some data with a peak in it
NBarSeries bar = new NBarSeries();
m_Chart.Series.Add(bar);
bar.DataLabelStyle = new NDataLabelStyle(false);
// fill in some data so that it contains several peaks of data
Random random = new Random();
for (int i = 0; i < 8; i++)
{
bar.DataPoints.Add(new NBarDataPoint(random.Next(30)));
}
for (int i = 0; i < 5; i++)
{
bar.DataPoints.Add(new NBarDataPoint(300 + random.Next(50)));
}
for (int i = 0; i < 8; i++)
{
bar.DataPoints.Add(new NBarDataPoint(random.Next(30)));
}
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NComboBox styleComboBox = new NComboBox();
styleComboBox.Items.FillFromEnum();
styleComboBox.SelectedIndexChanged += OnStyleComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Style:", styleComboBox));
styleComboBox.SelectedIndex = (int)ENScaleBreakStyle.Wave;
NComboBox patternComboBox = new NComboBox();
patternComboBox.Items.FillFromEnum();
patternComboBox.SelectedIndexChanged += OnPatternComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Pattern:", patternComboBox));
NNumericUpDown horzStepUpDown = new NNumericUpDown();
horzStepUpDown.ValueChanged += OnHorzStepUpDownValueChanged;
stack.Add(NPairBox.Create("Horz Step:", horzStepUpDown));
horzStepUpDown.Value = 20;
NNumericUpDown vertStepUpDown = new NNumericUpDown();
vertStepUpDown.ValueChanged += OnVertStepUpDownValueChanged;
stack.Add(NPairBox.Create("Vert Step:", vertStepUpDown));
vertStepUpDown.Value = 10;
NNumericUpDown lengthUpDown = new NNumericUpDown();
lengthUpDown.ValueChanged += OnLengthUpDownValueChanged;
stack.Add(NPairBox.Create("Length:", lengthUpDown));
lengthUpDown.Value = 10;
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to change the appearance of scale breaks.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Scale Breaks", "https://www.nevron.com/docs/openvision/scale-breaks.html"),
("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"),
("Common Axis Functionality", "https://www.nevron.com/docs/openvision/chart-common-axis-functionality.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
void OnLengthUpDownValueChanged(NValueChangeEventArgs arg)
{
m_ScaleBreak.Length = ((NNumericUpDown)arg.TargetNode).Value;
}
void OnVertStepUpDownValueChanged(NValueChangeEventArgs arg)
{
m_ScaleBreak.VerticalStep = ((NNumericUpDown)arg.TargetNode).Value;
}
void OnHorzStepUpDownValueChanged(NValueChangeEventArgs arg)
{
m_ScaleBreak.HorizontalStep = ((NNumericUpDown)arg.TargetNode).Value;
}
void OnPatternComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_ScaleBreak.Pattern = (ENScaleBreakPattern)((NComboBox)arg.TargetNode).SelectedIndex;
}
void OnStyleComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_ScaleBreak.Style = (ENScaleBreakStyle)((NComboBox)arg.TargetNode).SelectedIndex;
}
#endregion
#region Fields
private NCartesianChart m_Chart;
private NScaleBreak m_ScaleBreak;
#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 - NScaleBreakAppearanceExample"
' 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)
' configure title
chartView.Surface.Titles(0).Text = "Scale Breaks Appearance"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart.Padding = New NMargins(20)
' configure axes
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear)
' configure scale
Dim yScale As NLinearScale = m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale
yScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick
m_ScaleBreak = New NAutoScaleBreak(0.4F)
m_ScaleBreak.PositionMode = ENScaleBreakPositionMode.Percent
yScale.ScaleBreaks.Add(m_ScaleBreak)
' add an interlaced strip to the Y axis
Dim interlacedStrip As NScaleStrip = New NScaleStrip()
interlacedStrip.Interlaced = True
interlacedStrip.Fill = New NColorFill(NColor.Beige)
yScale.Strips.Add(interlacedStrip)
' Create some data with a peak in it
Dim bar As NBarSeries = New NBarSeries()
m_Chart.Series.Add(bar)
bar.DataLabelStyle = New NDataLabelStyle(False)
' fill in some data so that it contains several peaks of data
Dim random As Random = New Random()
For i = 0 To 7
bar.DataPoints.Add(New NBarDataPoint(random.Next(30)))
Next
For i = 0 To 4
bar.DataPoints.Add(New NBarDataPoint(300 + random.Next(50)))
Next
For i = 0 To 7
bar.DataPoints.Add(New NBarDataPoint(random.Next(30)))
Next
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)
Dim styleComboBox As NComboBox = New NComboBox()
styleComboBox.Items.FillFromEnum(Of ENScaleBreakStyle)()
styleComboBox.SelectedIndexChanged += AddressOf OnStyleComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Style:", styleComboBox))
styleComboBox.SelectedIndex = CInt(ENScaleBreakStyle.Wave)
Dim patternComboBox As NComboBox = New NComboBox()
patternComboBox.Items.FillFromEnum(Of ENScaleBreakPattern)()
patternComboBox.SelectedIndexChanged += AddressOf OnPatternComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Pattern:", patternComboBox))
Dim horzStepUpDown As NNumericUpDown = New NNumericUpDown()
horzStepUpDown.ValueChanged += AddressOf OnHorzStepUpDownValueChanged
stack.Add(NPairBox.Create("Horz Step:", horzStepUpDown))
horzStepUpDown.Value = 20
Dim vertStepUpDown As NNumericUpDown = New NNumericUpDown()
vertStepUpDown.ValueChanged += AddressOf OnVertStepUpDownValueChanged
stack.Add(NPairBox.Create("Vert Step:", vertStepUpDown))
vertStepUpDown.Value = 10
Dim lengthUpDown As NNumericUpDown = New NNumericUpDown()
lengthUpDown.ValueChanged += AddressOf OnLengthUpDownValueChanged
stack.Add(NPairBox.Create("Length:", lengthUpDown))
lengthUpDown.Value = 10
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to change the appearance of scale breaks.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Scale Breaks", "https://www.nevron.com/docs/openvision/scale-breaks.html"), ("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"), ("Common Axis Functionality", "https://www.nevron.com/docs/openvision/chart-common-axis-functionality.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnLengthUpDownValueChanged(arg As NValueChangeEventArgs)
m_ScaleBreak.Length = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnVertStepUpDownValueChanged(arg As NValueChangeEventArgs)
m_ScaleBreak.VerticalStep = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnHorzStepUpDownValueChanged(arg As NValueChangeEventArgs)
m_ScaleBreak.HorizontalStep = CType(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnPatternComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_ScaleBreak.Pattern = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENScaleBreakPattern)
End Sub
Private Sub OnStyleComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_ScaleBreak.Style = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENScaleBreakStyle)
End Sub
#End Region
#Region "Fields"
Private m_Chart As NCartesianChart
Private m_ScaleBreak As NScaleBreak
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class