Standard 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.

Standard Line 3D Example for WPF Description

This example demonstrates how to create a standard 3D line chart.


Standard Line 3DExample

C# Standard 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.Editors;
using Nevron.Nov.Examples.Framework;
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 - NStandardLine3DExample";

			// 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 = "Standard 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.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective2);
            m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft);

			// configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard);
            m_Chart.Axes[ENCartesianAxis.Depth].Visible = false;
            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;
			strip.SetShowAtWall(ENChartWall.Back, true);
            strip.SetShowAtWall(ENChartWall.Left, true);
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);

			m_Line = new NLineSeries();
            m_Chart.Series.Add(m_Line);

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

			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 lineStyleCombo = new NComboBox();
            lineStyleCombo.Items.FillFromEnum();
            lineStyleCombo.SelectedIndexChanged += OnLineStyleComboSelectedIndexChanged;
            stack.Add(NPairBox.Create("Line Segment Shape:", lineStyleCombo));

            m_LineStrokeButton = new NButton("Line Stroke...");
            m_LineStrokeButton.Click += OnLineStrokeButtonClick;
            stack.Add(m_LineStrokeButton);

            m_LineFillButton = new NButton("Line Fill...");
            m_LineFillButton.Click += OnLineFillButtonClick;
            stack.Add(m_LineFillButton);

            m_LineDepthScrollBar = new NHScrollBar();
            m_LineDepthScrollBar.Minimum = 0;
            m_LineDepthScrollBar.Maximum = 100;
            m_LineDepthScrollBar.ValueChanged += OnLineDepthScrollBarValueChanged;
            m_LineDepthScrollBar.Value = 50;
            stack.Add(NPairBox.Create("Line Depth:", m_LineDepthScrollBar));

            m_LineSizeScrollBar = new NHScrollBar();
            m_LineSizeScrollBar.Minimum = 0;
            m_LineSizeScrollBar.Maximum = 5.0f;
            m_LineSizeScrollBar.SmallChange = 0.1f;
            m_LineSizeScrollBar.LargeChange = 0.2f;
            m_LineSizeScrollBar.ValueChanged += OnLineSizeScrollBarValueChanged;
            m_LineSizeScrollBar.Value = 2.0f;
            stack.Add(NPairBox.Create("Line Size:", m_LineSizeScrollBar));

            lineStyleCombo.SelectedIndex = (int)ENLineSegmentShape.Tape;

            return group;
		}
        /// 
        /// 
        /// 
        /// 
        private void OnLineDepthScrollBarValueChanged(NValueChangeEventArgs arg)
        {
            m_Line.DepthPercent = System.Convert.ToSingle(arg.NewValue);
        }
        /// 
        /// 
        /// 
        /// 
        private void OnLineSizeScrollBarValueChanged(NValueChangeEventArgs arg)
        {
            m_Line.LineSize = System.Convert.ToSingle(arg.NewValue);
        }
        /// 
        /// 
        /// 
        /// 
        private void OnLineFillButtonClick(NEventArgs arg)
        {
            try
            {
                NNode node = m_Line.Fill;
                NEditorWindow editorWindow = NEditorWindow.CreateForInstance(
                    node,
                    null,
                    this.DisplayWindow,
                    null);

                if (node is NStyleNodeCollectionTree)
                {
                    editorWindow.PreferredSize = new NSize(500, 360);
                }

                editorWindow.Open();
            }
            catch (Exception ex)
            {
                NTrace.WriteException("OnShowDesignerClick failed.", ex);
            }
        }
        /// 
        /// 
        /// 
        /// 
        private void OnLineStrokeButtonClick(NEventArgs arg)
        {
            try
            {
                NNode node = m_Line.Stroke;
                NEditorWindow editorWindow = NEditorWindow.CreateForInstance(
                    node,
                    null,
                    this.DisplayWindow,
                    null);

                if (node is NStyleNodeCollectionTree)
                {
                    editorWindow.PreferredSize = new NSize(500, 360);
                }

                editorWindow.Open();
            }
            catch (Exception ex)
            {
                NTrace.WriteException("OnShowDesignerClick failed.", ex);
            }
        }
        /// 
        /// 
        /// 
        /// 
        private void OnLineStyleComboSelectedIndexChanged(NValueChangeEventArgs arg)
        {
            m_Line.LineSegmentShape = (ENLineSegmentShape)arg.NewValue;

            switch (m_Line.LineSegmentShape)
            {
                case ENLineSegmentShape.Line: // simple line
                    m_LineDepthScrollBar.Enabled = false;
                    m_LineSizeScrollBar.Enabled = false;
                    m_LineFillButton.Enabled = false;
                    SetupTubeMarkers(m_Line.MarkerStyle);
                    break;

                case ENLineSegmentShape.Tape: // tape
                    m_LineDepthScrollBar.Enabled = true;
                    m_LineSizeScrollBar.Enabled = false;
                    m_LineFillButton.Enabled = true;
                    SetupTapeMarkers(m_Line.MarkerStyle);
                    break;

                case ENLineSegmentShape.Tube: // tube
                    m_LineDepthScrollBar.Enabled = false;
                    m_LineSizeScrollBar.Enabled = true;
                    m_LineFillButton.Enabled = true;
                    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;
        }

        public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create a standard 3D line chart.

"; } /// /// 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 #endregion #region Event Handlers #endregion #region Fields NCartesianChart m_Chart; NLineSeries m_Line; NButton m_LineStrokeButton; NButton m_LineFillButton; NHScrollBar m_LineDepthScrollBar; NHScrollBar m_LineSizeScrollBar; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

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

VB.NET Standard 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.Editors
Imports Nevron.Nov.Examples.Framework
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 - NStandardLine3DExample"

		' 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 = "Standard 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.Projection.SetPredefinedProjection(ENPredefinedProjection.Perspective2)
            m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft)

            ' configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard)
            m_Chart.Axes(ENCartesianAxis.Depth).Visible = False
            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
            strip.SetShowAtWall(ENChartWall.Back, True)
            strip.SetShowAtWall(ENChartWall.Left, True)
            m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale.Strips.Add(strip)

            m_Line = New NLineSeries()
            m_Chart.Series.Add(m_Line)

            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

            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 lineStyleCombo As NComboBox = New NComboBox()
            lineStyleCombo.Items.FillFromEnum(Of ENLineSegmentShape)()
            lineStyleCombo.SelectedIndexChanged += AddressOf OnLineStyleComboSelectedIndexChanged
            stack.Add(NPairBox.Create("Line Segment Shape:", lineStyleCombo))

            m_LineStrokeButton = New NButton("Line Stroke...")
            Me.m_LineStrokeButton.Click += AddressOf OnLineStrokeButtonClick
            stack.Add(m_LineStrokeButton)

            m_LineFillButton = New NButton("Line Fill...")
            Me.m_LineFillButton.Click += AddressOf OnLineFillButtonClick
            stack.Add(m_LineFillButton)

            m_LineDepthScrollBar = New NHScrollBar()
            m_LineDepthScrollBar.Minimum = 0
            m_LineDepthScrollBar.Maximum = 100
            Me.m_LineDepthScrollBar.ValueChanged += AddressOf OnLineDepthScrollBarValueChanged
            m_LineDepthScrollBar.Value = 50
            stack.Add(NPairBox.Create("Line Depth:", m_LineDepthScrollBar))

            m_LineSizeScrollBar = New NHScrollBar()
            m_LineSizeScrollBar.Minimum = 0
            m_LineSizeScrollBar.Maximum = 5.0F
            m_LineSizeScrollBar.SmallChange = 0.1F
            m_LineSizeScrollBar.LargeChange = 0.2F
            Me.m_LineSizeScrollBar.ValueChanged += AddressOf OnLineSizeScrollBarValueChanged
            m_LineSizeScrollBar.Value = 2.0F
            stack.Add(NPairBox.Create("Line Size:", m_LineSizeScrollBar))

            lineStyleCombo.SelectedIndex = CInt(ENLineSegmentShape.Tape)

            Return group
        End Function
        ''' 
        ''' 
        ''' 
        ''' 
        Private Sub OnLineDepthScrollBarValueChanged(arg As NValueChangeEventArgs)
            m_Line.DepthPercent = Convert.ToSingle(arg.NewValue)
        End Sub
        ''' 
        ''' 
        ''' 
        ''' 
        Private Sub OnLineSizeScrollBarValueChanged(arg As NValueChangeEventArgs)
            m_Line.LineSize = Convert.ToSingle(arg.NewValue)
        End Sub
        ''' 
        ''' 
        ''' 
        ''' 
        Private Sub OnLineFillButtonClick(arg As NEventArgs)
            Try
                Dim node As NNode = m_Line.Fill
                Dim editorWindow = NEditorWindow.CreateForInstance(node, Nothing, Me.DisplayWindow, Nothing)

                If TypeOf node Is NStyleNodeCollectionTree Then
                    editorWindow.PreferredSize = New NSize(500, 360)
                End If

                editorWindow.Open()
            Catch ex As Exception
                NTrace.WriteException("OnShowDesignerClick failed.", ex)
            End Try
        End Sub
        ''' 
        ''' 
        ''' 
        ''' 
        Private Sub OnLineStrokeButtonClick(arg As NEventArgs)
            Try
                Dim node As NNode = m_Line.Stroke
                Dim editorWindow = NEditorWindow.CreateForInstance(node, Nothing, Me.DisplayWindow, Nothing)

                If TypeOf node Is NStyleNodeCollectionTree Then
                    editorWindow.PreferredSize = New NSize(500, 360)
                End If

                editorWindow.Open()
            Catch ex As Exception
                NTrace.WriteException("OnShowDesignerClick failed.", ex)
            End Try
        End Sub
        ''' 
        ''' 
        ''' 
        ''' 
        Private Sub OnLineStyleComboSelectedIndexChanged(arg As NValueChangeEventArgs)
            m_Line.LineSegmentShape = CType(arg.NewValue, ENLineSegmentShape)

            Select Case m_Line.LineSegmentShape
                Case ENLineSegmentShape.Line ' simple line
                    m_LineDepthScrollBar.Enabled = False
                    m_LineSizeScrollBar.Enabled = False
                    m_LineFillButton.Enabled = False
                    SetupTubeMarkers(m_Line.MarkerStyle)

                Case ENLineSegmentShape.Tape ' tape
                    m_LineDepthScrollBar.Enabled = True
                    m_LineSizeScrollBar.Enabled = False
                    m_LineFillButton.Enabled = True
                    SetupTapeMarkers(m_Line.MarkerStyle)

                Case ENLineSegmentShape.Tube ' tube
                    m_LineDepthScrollBar.Enabled = False
                    m_LineSizeScrollBar.Enabled = True
                    m_LineFillButton.Enabled = True
                    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

        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to create a standard 3D line chart.

" 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" #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_Chart As NCartesianChart Private m_Line As NLineSeries Private m_LineStrokeButton As NButton Private m_LineFillButton As NButton Private m_LineDepthScrollBar As NHScrollBar Private m_LineSizeScrollBar As NHScrollBar #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) Standard Line 3D Example for WPF Solution