XYZ Range 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.

XYZ Range Example for WPF Description

This example demonstrates how to create a 3D range m_Chart.


XYZRange Example

C# XYZ Range 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.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NXYZRangeExample";

			// 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 = "XYZ Range Series";

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

            m_Chart.Enable3D = true;
			m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted);
            m_Chart.Projection.Rotation = -18;
            m_Chart.Projection.Elevation = 13;
			m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight);
            m_Chart.ModelDepth = 55.0f;
            m_Chart.ModelWidth = 55.0f;
            m_Chart.ModelHeight = 55.0f;
			m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear);
            m_Chart.Interactor = new NInteractor(new NTrackballTool());

            // setup X axis
            {
				NLinearScale scaleX = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale;
				scaleX.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
				scaleX.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
				scaleX.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
				m_Chart.Axes[ENCartesianAxis.PrimaryX].SetFixedViewRange(0, 20);
			}

			// setup Y axis
			{
				NLinearScale scaleY = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;
                scaleY.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
				scaleY.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
				scaleY.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;

				// add interlaced stripe
				NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
				stripStyle.SetShowAtWall(ENChartWall.Back, true);
				stripStyle.SetShowAtWall(ENChartWall.Left, true);
				stripStyle.Interlaced = true;
                scaleY.Strips.Add(stripStyle);

                m_Chart.Axes[ENCartesianAxis.PrimaryY].SetFixedViewRange(0, 20);
            }

			// setup Depth axis
			{
				NLinearScale scaleZ = (NLinearScale)m_Chart.Axes[ENCartesianAxis.Depth].Scale;
                scaleZ.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
				scaleZ.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
				scaleZ.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
                m_Chart.Axes[ENCartesianAxis.Depth].SetFixedViewRange(0, 20);
            }

			// setup shape series
			m_Range = new NRangeSeries();
			m_Chart.Series.Add(m_Range);

            m_Range.Fill = new NColorFill(NColor.Red);
            m_Range.Stroke = new NStroke(NColor.DarkRed);
            m_Range.LegendView.Mode = ENSeriesLegendMode.None;
            m_Range.UseXValues = true;
            m_Range.UseZValues = true;

            // add data
            m_Range.DataPoints.Add(new NRangeDataPoint(1, 11, 5, 5, 17, 9));
            m_Range.DataPoints.Add(new NRangeDataPoint(4, 15, 16, 7, 19, 19));
            m_Range.DataPoints.Add(new NRangeDataPoint(5, 6, 12, 15, 11, 18));
            m_Range.DataPoints.Add(new NRangeDataPoint(9, 2, 3, 14, 5, 5));
            m_Range.DataPoints.Add(new NRangeDataPoint(15, 2, 3, 19, 5, 5));

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

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			NComboBox rangeShapeComboBox = new NComboBox();
			rangeShapeComboBox.Items.FillFromEnum();
			rangeShapeComboBox.SelectedIndexChanged += OnRangeShapeComboBoxSelectedIndexChanged;
			stack.Add(NPairBox.Create("Range Shape: ", rangeShapeComboBox));

			NCheckBox showDataLabels = new NCheckBox("Show Data Labels");
			showDataLabels.CheckedChanged += OnShowDataLabelsCheckedChanged;
			showDataLabels.Checked = false;
            stack.Add(showDataLabels);

			rangeShapeComboBox.SelectedIndex = (int)ENBarShape.Rectangle;
			showDataLabels.Checked = false;

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

This example demonstrates how to create a 3D range m_Chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Range Series", "https://www.nevron.com/docs/openvision/range-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 void OnShowDataLabelsCheckedChanged(NValueChangeEventArgs arg) { if ((arg.TargetNode as NCheckBox).Checked) { m_Range.DataLabelStyle = new NDataLabelStyle(true); m_Range.DataLabelStyle.Format = ""; } else { m_Range.DataLabelStyle = new NDataLabelStyle(false); } } void OnRangeShapeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg) { m_Range.Shape = (ENBarShape)(arg.TargetNode as NComboBox).SelectedIndex; } #endregion #region Fields NRangeSeries m_Range; NCartesianChart m_Chart; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) XYZ Range Example for WPF Solution

VB.NET XYZ Range 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

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

		' 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 = "XYZ Range Series"

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

            m_Chart.Enable3D = True
            m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted)
            m_Chart.Projection.Rotation = -18
            m_Chart.Projection.Elevation = 13
            m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight)
            m_Chart.ModelDepth = 55.0F
            m_Chart.ModelWidth = 55.0F
            m_Chart.ModelHeight = 55.0F
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear)
            m_Chart.Interactor = New NInteractor(New NTrackballTool())

            ' setup X axis
            If True Then
                Dim scaleX As NLinearScale = m_Chart.Axes(ENCartesianAxis.PrimaryX).Scale
                scaleX.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
                scaleX.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
                scaleX.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
                m_Chart.Axes(ENCartesianAxis.PrimaryX).SetFixedViewRange(0, 20)
            End If

            ' setup Y axis
            If True Then
                Dim scaleY As NLinearScale = m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale
                scaleY.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
                scaleY.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
                scaleY.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot

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

                m_Chart.Axes(ENCartesianAxis.PrimaryY).SetFixedViewRange(0, 20)
            End If

            ' setup Depth axis
            If True Then
                Dim scaleZ As NLinearScale = m_Chart.Axes(ENCartesianAxis.Depth).Scale
                scaleZ.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
                scaleZ.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
                scaleZ.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
                m_Chart.Axes(ENCartesianAxis.Depth).SetFixedViewRange(0, 20)
            End If

            ' setup shape series
            m_Range = New NRangeSeries()
            m_Chart.Series.Add(m_Range)

            m_Range.Fill = New NColorFill(NColor.Red)
            m_Range.Stroke = New NStroke(NColor.DarkRed)
            m_Range.LegendView.Mode = ENSeriesLegendMode.None
            m_Range.UseXValues = True
            m_Range.UseZValues = True

            ' add data
            m_Range.DataPoints.Add(New NRangeDataPoint(1, 11, 5, 5, 17, 9))
            m_Range.DataPoints.Add(New NRangeDataPoint(4, 15, 16, 7, 19, 19))
            m_Range.DataPoints.Add(New NRangeDataPoint(5, 6, 12, 15, 11, 18))
            m_Range.DataPoints.Add(New NRangeDataPoint(9, 2, 3, 14, 5, 5))
            m_Range.DataPoints.Add(New NRangeDataPoint(15, 2, 3, 19, 5, 5))

            chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints))

            Return chartViewWithCommandBars
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)

            Dim rangeShapeComboBox As NComboBox = New NComboBox()
            rangeShapeComboBox.Items.FillFromEnum(Of ENBarShape)()
            rangeShapeComboBox.SelectedIndexChanged += AddressOf OnRangeShapeComboBoxSelectedIndexChanged
            stack.Add(NPairBox.Create("Range Shape: ", rangeShapeComboBox))

            Dim showDataLabels As NCheckBox = New NCheckBox("Show Data Labels")
            showDataLabels.CheckedChanged += AddressOf OnShowDataLabelsCheckedChanged
            showDataLabels.Checked = False
            stack.Add(showDataLabels)

            rangeShapeComboBox.SelectedIndex = CInt(ENBarShape.Rectangle)
            showDataLabels.Checked = False

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

This example demonstrates how to create a 3D range m_Chart.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Range Series", "https://www.nevron.com/docs/openvision/range-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" Private Sub OnShowDataLabelsCheckedChanged(arg As NValueChangeEventArgs) If TryCast(arg.TargetNode, NCheckBox).Checked Then m_Range.DataLabelStyle = New NDataLabelStyle(True) m_Range.DataLabelStyle.Format = "" Else m_Range.DataLabelStyle = New NDataLabelStyle(False) End If End Sub Private Sub OnRangeShapeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs) m_Range.Shape = CType(TryCast(arg.TargetNode, NComboBox).SelectedIndex, ENBarShape) End Sub #End Region #Region "Fields" Private m_Range As NRangeSeries Private m_Chart As NCartesianChart #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) XYZ Range Example for WPF Solution