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
}
}