Step Line 3D 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.

Step Line 3D Example for WPF Description

This example demonstrates how to create step line charts.


Step Line 3DExample

C# Step Line 3D Example Code for Nevron Chart for WPF
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Chart.Tools;
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 - NStepLine3DExample";

			// 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 = "Step Line 3D";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.Enable3D = true;
            m_Chart.ModelWidth = 65;
            m_Chart.ModelHeight = 40;

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard);
            m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective2);
            m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft);
            m_Chart.Interactor = new NInteractor(new NTrackballTool());

            // add interlaced stripe to the Y axis
            NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);
			strip.Interlaced = true;
			m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);

			m_Line = new NLineSeries();
			m_Line.Name = "Line Series";
			m_Line.InflateMargins = true;
			m_Line.DataLabelStyle = new NDataLabelStyle("");
			m_Line.MarkerStyle = new NMarkerStyle(new NSize(4, 4));

			Random random = new Random();

			for (int i = 0; i < 8; i++)
			{
				m_Line.DataPoints.Add(new NLineDataPoint(random.Next(80) + 20));
			}

			m_Chart.Series.Add(m_Line);

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

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			NComboBox lineSegmentModeComboBox = new NComboBox();

			lineSegmentModeComboBox.Items.Add(new NComboBoxItem("HV Step Line"));
			lineSegmentModeComboBox.Items.Add(new NComboBoxItem("VH Step Line"));
			lineSegmentModeComboBox.Items.Add(new NComboBoxItem("HV Ascending VH Descending Step Line"));
			lineSegmentModeComboBox.Items.Add(new NComboBoxItem("VH Ascending HV Descending Step Line"));

			lineSegmentModeComboBox.SelectedIndexChanged += OnLineSegmentModeComboBoxSelectedIndexChanged;
			lineSegmentModeComboBox.SelectedIndex = 0;

			stack.Add(NPairBox.Create("Mode:", lineSegmentModeComboBox));

            NComboBox lineStyleCombo = new NComboBox();
            lineStyleCombo.Items.FillFromEnum();
            lineStyleCombo.SelectedIndexChanged += OnLineStyleComboSelectedIndexChanged;
            lineStyleCombo.SelectedIndex = (int)ENLineSegmentShape.Tape;
            stack.Add(NPairBox.Create("Line Segment Shape:", lineStyleCombo));

            return group;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create step line charts.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Line Series", "https://www.nevron.com/docs/openvision/line-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"), }; } #endregion #region Implementation void OnLineSegmentModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { switch (((NComboBox)arg.TargetNode).SelectedIndex) { case 0: m_Line.LineSegmentMode = ENLineSegmentMode.HVStep; break; case 1: m_Line.LineSegmentMode = ENLineSegmentMode.VHStep; break; case 2: m_Line.LineSegmentMode = ENLineSegmentMode.HVAscentVHDescentStep; break; case 3: m_Line.LineSegmentMode = ENLineSegmentMode.VHAscentHVDescentStep; break; } } #endregion #region Event Handlers /// /// /// /// private void OnLineStyleComboSelectedIndexChanged(NValueChangeEventArgs arg) { m_Line.LineSegmentShape = (ENLineSegmentShape)arg.NewValue; switch (m_Line.LineSegmentShape) { case ENLineSegmentShape.Line: // simple line SetupTubeMarkers(m_Line.MarkerStyle); break; case ENLineSegmentShape.Tape: // tape SetupTapeMarkers(m_Line.MarkerStyle); break; case ENLineSegmentShape.Tube: // tube SetupTubeMarkers(m_Line.MarkerStyle); break; } } private void SetupTapeMarkers(NMarkerStyle marker) { marker.Shape = ENPointShape3D.Cylinder; marker.AutoDepth = true; marker.AutoDepthPercent = 120; } private void SetupTubeMarkers(NMarkerStyle marker) { marker.Shape = ENPointShape3D.Sphere; marker.AutoDepth = false; marker.Width = 10; marker.Height = 10; marker.Depth = 10; } #endregion #region Fields NCartesianChart m_Chart; NLineSeries m_Line; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Step Line 3D Example for WPF Solution

VB.NET Step Line 3D Example Code for Nevron Chart for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Chart.Tools
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 - NStepLine3DExample"

		' 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 = "Step Line 3D"

            ' configure chart
            m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
            m_Chart.Enable3D = True
            m_Chart.ModelWidth = 65
            m_Chart.ModelHeight = 40

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard)
            m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective2)
            m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft)
            m_Chart.Interactor = New NInteractor(New NTrackballTool())

            ' add interlaced stripe to the Y axis
            Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(ENNamedColor.Beige), Nothing, True, 0, 0, 1, 1)
            strip.Interlaced = True
            m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale.Strips.Add(strip)

            m_Line = New NLineSeries()
            m_Line.Name = "Line Series"
            m_Line.InflateMargins = True
            m_Line.DataLabelStyle = New NDataLabelStyle("")
            m_Line.MarkerStyle = New NMarkerStyle(New NSize(4, 4))

            Dim random As Random = New Random()

            For i = 0 To 7
                m_Line.DataPoints.Add(New NLineDataPoint(random.Next(80) + 20))
            Next

            m_Chart.Series.Add(m_Line)

            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 lineSegmentModeComboBox As NComboBox = New NComboBox()

            lineSegmentModeComboBox.Items.Add(New NComboBoxItem("HV Step Line"))
            lineSegmentModeComboBox.Items.Add(New NComboBoxItem("VH Step Line"))
            lineSegmentModeComboBox.Items.Add(New NComboBoxItem("HV Ascending VH Descending Step Line"))
            lineSegmentModeComboBox.Items.Add(New NComboBoxItem("VH Ascending HV Descending Step Line"))

            lineSegmentModeComboBox.SelectedIndexChanged += AddressOf OnLineSegmentModeComboBoxSelectedIndexChanged
            lineSegmentModeComboBox.SelectedIndex = 0

            stack.Add(NPairBox.Create("Mode:", lineSegmentModeComboBox))

            Dim lineStyleCombo As NComboBox = New NComboBox()
            lineStyleCombo.Items.FillFromEnum(Of ENLineSegmentShape)()
            lineStyleCombo.SelectedIndexChanged += AddressOf OnLineStyleComboSelectedIndexChanged
            lineStyleCombo.SelectedIndex = CInt(ENLineSegmentShape.Tape)
            stack.Add(NPairBox.Create("Line Segment Shape:", lineStyleCombo))

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

This example demonstrates how to create step line charts.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Line Series", "https://www.nevron.com/docs/openvision/line-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html")} End Function #End Region #Region "Implementation" Private Sub OnLineSegmentModeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs) Select Case CType(arg.TargetNode, NComboBox).SelectedIndex Case 0 m_Line.LineSegmentMode = ENLineSegmentMode.HVStep Case 1 m_Line.LineSegmentMode = ENLineSegmentMode.VHStep Case 2 m_Line.LineSegmentMode = ENLineSegmentMode.HVAscentVHDescentStep Case 3 m_Line.LineSegmentMode = ENLineSegmentMode.VHAscentHVDescentStep End Select End Sub #End Region #Region "Event Handlers" ''' ''' ''' ''' Private Sub OnLineStyleComboSelectedIndexChanged(arg As NValueChangeEventArgs) m_Line.LineSegmentShape = CType(arg.NewValue, ENLineSegmentShape) Select Case m_Line.LineSegmentShape Case ENLineSegmentShape.Line ' simple line SetupTubeMarkers(m_Line.MarkerStyle) Case ENLineSegmentShape.Tape ' tape SetupTapeMarkers(m_Line.MarkerStyle) Case ENLineSegmentShape.Tube ' tube SetupTubeMarkers(m_Line.MarkerStyle) End Select End Sub Private Sub SetupTapeMarkers(marker As NMarkerStyle) marker.Shape = ENPointShape3D.Cylinder marker.AutoDepth = True marker.AutoDepthPercent = 120 End Sub Private Sub SetupTubeMarkers(marker As NMarkerStyle) marker.Shape = ENPointShape3D.Sphere marker.AutoDepth = False marker.Width = 10 marker.Height = 10 marker.Depth = 10 End Sub #End Region #Region "Fields" Private m_Chart As NCartesianChart Private m_Line As NLineSeries #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) Step Line 3D Example for WPF Solution