Three Line Break Example for WPF

Nevron NOV Chart for WPF ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WPF Chart examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Three Line Break Example for WPF Description

This example demonstrates the functionality of the three line break series.


Three Line Break Example

C# Three Line Break Example Code for Nevron Chart for WPF
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 - NThreeLineBreakExample";

			// 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 = "Three Line Break";

			// configure chart
			NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];

			chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

			NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;

			// add interlace stripe
			NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
			stripStyle.Interlaced = true;
			scaleY.Strips.Add(stripStyle);

			// setup X axis
			NPriceTimeScale priceScale = new NPriceTimeScale();
			priceScale.InnerMajorTicks.Stroke = new NStroke(0.0, NColor.Black);
			chart.Axes[ENCartesianAxis.PrimaryX].Scale = priceScale;

			// setup line break series
			m_ThreeLineBreak = new NThreeLineBreakSeries();
			m_ThreeLineBreak.UseXValues = true;
			chart.Series.Add(m_ThreeLineBreak);

			GenerateData(m_ThreeLineBreak);
			
			chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			NNumericUpDown boxWidthPercentUpDown = new NNumericUpDown();
			boxWidthPercentUpDown.Minimum = 0;
			boxWidthPercentUpDown.Maximum = 100;
			boxWidthPercentUpDown.Value = m_ThreeLineBreak.BoxWidthPercent;
			boxWidthPercentUpDown.ValueChanged += OnBoxWidthPercentUpDownValueChanged;
			stack.Add(NPairBox.Create("Box Width Percent:", boxWidthPercentUpDown));

			NNumericUpDown numberOfLinesToBreakUpDown = new NNumericUpDown();
			numberOfLinesToBreakUpDown.Minimum = 1;
			numberOfLinesToBreakUpDown.Maximum = 100;
			numberOfLinesToBreakUpDown.Value = m_ThreeLineBreak.NumberOfLinesToBreak;
			numberOfLinesToBreakUpDown.ValueChanged += OnNumberOfLinesToBreakUpDownValueChanged;
			numberOfLinesToBreakUpDown.DecimalPlaces = 0;
			stack.Add(NPairBox.Create("Number of Lines to Break:", numberOfLinesToBreakUpDown));
						
			return group;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates the functionality of the three line break series.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Chart Types Overview", "https://www.nevron.com/docs/openvision/chart-types-overview.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"), ("Stock Series", "https://www.nevron.com/docs/openvision/stock-chart-series.html"), ("Cartesian Chart", "https://www.nevron.com/docs/openvision/cartesian-chart.html"), ("DateTime Scale", "https://www.nevron.com/docs/openvision/datetime-scale.html"), }; } #endregion #region Implementation private void GenerateData(NThreeLineBreakSeries threeLineBreak) { NStockDataGenerator dataGenerator = new NStockDataGenerator(new NRange(50, 350), 0.002, 2); dataGenerator.Reset(); DateTime dt = DateTime.Now; for (int i = 0; i < 100; i++) { threeLineBreak.DataPoints.Add(new NThreeLineBreakDataPoint(NDateTimeHelpers.ToOADate(dt), dataGenerator.GetNextValue())); dt = dt.AddDays(1); } } #endregion #region Event Handlers void OnBoxWidthPercentUpDownValueChanged(NValueChangeEventArgs arg) { m_ThreeLineBreak.BoxWidthPercent = ((NNumericUpDown)arg.TargetNode).Value; } void OnNumberOfLinesToBreakUpDownValueChanged(NValueChangeEventArgs arg) { m_ThreeLineBreak.NumberOfLinesToBreak = (int)((NNumericUpDown)arg.TargetNode).Value; } #endregion #region Fields NThreeLineBreakSeries m_ThreeLineBreak; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Three Line Break Example for WPF Solution

VB.NET Three Line Break Example Code for Nevron Chart for WPF
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

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 - NThreeLineBreakExample"

		' 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 = "Three Line Break"

            ' configure chart
            Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear)

            Dim scaleY As NLinearScale = chart.Axes(ENCartesianAxis.PrimaryY).Scale

            ' add interlace stripe
            Dim stripStyle As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
            stripStyle.Interlaced = True
            scaleY.Strips.Add(stripStyle)

            ' setup X axis
            Dim priceScale As NPriceTimeScale = New NPriceTimeScale()
            priceScale.InnerMajorTicks.Stroke = New NStroke(0.0, NColor.Black)
            chart.Axes(ENCartesianAxis.PrimaryX).Scale = priceScale

            ' setup line break series
            m_ThreeLineBreak = New NThreeLineBreakSeries()
            m_ThreeLineBreak.UseXValues = True
            chart.Series.Add(m_ThreeLineBreak)

            GenerateData(m_ThreeLineBreak)

            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 boxWidthPercentUpDown As NNumericUpDown = New NNumericUpDown()
            boxWidthPercentUpDown.Minimum = 0
            boxWidthPercentUpDown.Maximum = 100
            boxWidthPercentUpDown.Value = m_ThreeLineBreak.BoxWidthPercent
            boxWidthPercentUpDown.ValueChanged += AddressOf OnBoxWidthPercentUpDownValueChanged
            stack.Add(NPairBox.Create("Box Width Percent:", boxWidthPercentUpDown))

            Dim numberOfLinesToBreakUpDown As NNumericUpDown = New NNumericUpDown()
            numberOfLinesToBreakUpDown.Minimum = 1
            numberOfLinesToBreakUpDown.Maximum = 100
            numberOfLinesToBreakUpDown.Value = m_ThreeLineBreak.NumberOfLinesToBreak
            numberOfLinesToBreakUpDown.ValueChanged += AddressOf OnNumberOfLinesToBreakUpDownValueChanged
            numberOfLinesToBreakUpDown.DecimalPlaces = 0
            stack.Add(NPairBox.Create("Number of Lines to Break:", numberOfLinesToBreakUpDown))

            Return group
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates the functionality of the three line break series.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Chart Types Overview", "https://www.nevron.com/docs/openvision/chart-types-overview.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"), ("Stock Series", "https://www.nevron.com/docs/openvision/stock-chart-series.html"), ("Cartesian Chart", "https://www.nevron.com/docs/openvision/cartesian-chart.html"), ("DateTime Scale", "https://www.nevron.com/docs/openvision/datetime-scale.html")} End Function #End Region #Region "Implementation" Private Sub GenerateData(threeLineBreak As NThreeLineBreakSeries) Dim dataGenerator As NStockDataGenerator = New NStockDataGenerator(New NRange(50, 350), 0.002, 2) dataGenerator.Reset() Dim dt = Date.Now For i = 0 To 99 threeLineBreak.DataPoints.Add(New NThreeLineBreakDataPoint(NDateTimeHelpers.ToOADate(dt), dataGenerator.GetNextValue())) dt = dt.AddDays(1) Next End Sub #End Region #Region "Event Handlers" Private Sub OnBoxWidthPercentUpDownValueChanged(arg As NValueChangeEventArgs) m_ThreeLineBreak.BoxWidthPercent = CType(arg.TargetNode, NNumericUpDown).Value End Sub Private Sub OnNumberOfLinesToBreakUpDownValueChanged(arg As NValueChangeEventArgs) m_ThreeLineBreak.NumberOfLinesToBreak = CInt(CType(arg.TargetNode, NNumericUpDown).Value) End Sub #End Region #Region "Fields" Private m_ThreeLineBreak As NThreeLineBreakSeries #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Three Line Break Example for WPF Solution