Standard Funnel Example for WinForms

Nevron NOV Chart for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms 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 Funnel Example for WinForms Description

This example demonstrates how to create a standard funnel chart.


Standard Funnel Example

C# Standard Funnel Example Code for Nevron Chart for WinForms
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.Windows.Forms;

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

		public Form1()
		{
			InitializeComponent();

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

			// 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.Funnel);

			// configure title
			chartView.Surface.Titles[0].Text = "Standard Funnel";

			NFunnelChart funnelChart = (NFunnelChart)chartView.Surface.Charts[0];

			m_FunnelSeries = new NFunnelSeries();
			funnelChart.Series.Add(m_FunnelSeries);

			m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(20.0, "Awareness"));
			m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(10.0, "First Hear"));
			m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(15.0, "Further Learn"));
			m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(7.0, "Liking"));
			m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(28.0, "Decision"));
			m_FunnelSeries.DataLabelStyle = new NDataLabelStyle(true);
			m_FunnelSeries.DataLabelStyle.VertAlign = ENVerticalAlignment.Center;

            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 funnelShapeCombo = new NComboBox();
			funnelShapeCombo.Items.FillFromEnum();
			funnelShapeCombo.SelectedIndexChanged += OnFunnelShapeComboSelectedIndexChanged;
			funnelShapeCombo.SelectedIndex = (int)ENFunnelShape.Trapezoid;
			stack.Add(NPairBox.Create("Funnel Shape:", funnelShapeCombo));

			NComboBox labelAligmentModeCombo = new NComboBox();
			labelAligmentModeCombo.Items.FillFromEnum();
			labelAligmentModeCombo.SelectedIndexChanged += OnLabelAligmentModeComboSelectedIndexChanged;
			labelAligmentModeCombo.SelectedIndex = (int)ENFunnelLabelMode.Center;
			stack.Add(NPairBox.Create("Label Alignment:", labelAligmentModeCombo));

			NNumericUpDown labelArrowLengthUpDown = new NNumericUpDown();
			labelArrowLengthUpDown.Value = m_FunnelSeries.LabelArrowLength;
			labelArrowLengthUpDown.ValueChanged += OnLabelArrowLengthUpDownValueChanged;
			stack.Add(NPairBox.Create("Label Arrow Length:", labelArrowLengthUpDown));

			NNumericUpDown pointGapUpDown = new NNumericUpDown();
			pointGapUpDown.Value = m_FunnelSeries.PointGapPercent;
			pointGapUpDown.ValueChanged += OnPointGapUpDownValueChanged;
			stack.Add(NPairBox.Create("Point Gap Percent:", pointGapUpDown));

            NNumericUpDown neckHeightPercentUpDown = new NNumericUpDown();
            neckHeightPercentUpDown.Value = m_FunnelSeries.NeckHeightPercent;
            neckHeightPercentUpDown.ValueChanged += OnNeckHeightPercentUpDownValueChanged;
            stack.Add(NPairBox.Create("Neck Height Percent:", neckHeightPercentUpDown));

            NNumericUpDown neckWidthPercentUpDown = new NNumericUpDown();
            neckWidthPercentUpDown.Value = m_FunnelSeries.NeckWidthPercent;
            neckWidthPercentUpDown.ValueChanged += OnNeckWidthPercentUpDownValueChanged;
            stack.Add(NPairBox.Create("Neck Width Percent:", neckWidthPercentUpDown));

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

This example demonstrates how to create a standard funnel chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Funnel Series", "https://www.nevron.com/docs/openvision/funnel-chart-series.html"), ("Funnel Chart", "https://www.nevron.com/docs/openvision/funnel-chart.html"), }; } #endregion #region Implementation #endregion #region Event Handlers void OnLabelArrowLengthUpDownValueChanged(NValueChangeEventArgs arg) { m_FunnelSeries.LabelArrowLength = ((NNumericUpDown)arg.TargetNode).Value; } void OnLabelAligmentModeComboSelectedIndexChanged(NValueChangeEventArgs arg) { m_FunnelSeries.LabelMode = (ENFunnelLabelMode)((NComboBox)arg.TargetNode).SelectedIndex; } void OnPointGapUpDownValueChanged(NValueChangeEventArgs arg) { m_FunnelSeries.PointGapPercent = ((NNumericUpDown)arg.TargetNode).Value; } void OnFunnelShapeComboSelectedIndexChanged(NValueChangeEventArgs arg) { m_FunnelSeries.Shape = (ENFunnelShape)((NComboBox)arg.TargetNode).SelectedIndex; } private void OnNeckHeightPercentUpDownValueChanged(NValueChangeEventArgs arg) { m_FunnelSeries.NeckHeightPercent = ((NNumericUpDown)arg.TargetNode).Value; } private void OnNeckWidthPercentUpDownValueChanged(NValueChangeEventArgs arg) { m_FunnelSeries.NeckWidthPercent = ((NNumericUpDown)arg.TargetNode).Value; } #endregion #region Fields NFunnelSeries m_FunnelSeries; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Standard Funnel Example for WinForms Solution

VB.NET Standard Funnel Example Code for Nevron Chart for WinForms
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.Forms

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NStandardFunnelExample"

        ' 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)
        host.Dock = DockStyle.Fill
        Controls.Add(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.Funnel)

            ' configure title
            chartView.Surface.Titles(0).Text = "Standard Funnel"

            Dim funnelChart = CType(chartView.Surface.Charts(0), NFunnelChart)

            m_FunnelSeries = New NFunnelSeries()
            funnelChart.Series.Add(m_FunnelSeries)

            m_FunnelSeries.DataPoints.Add(New NFunnelDataPoint(20.0, "Awareness"))
            m_FunnelSeries.DataPoints.Add(New NFunnelDataPoint(10.0, "First Hear"))
            m_FunnelSeries.DataPoints.Add(New NFunnelDataPoint(15.0, "Further Learn"))
            m_FunnelSeries.DataPoints.Add(New NFunnelDataPoint(7.0, "Liking"))
            m_FunnelSeries.DataPoints.Add(New NFunnelDataPoint(28.0, "Decision"))
            m_FunnelSeries.DataLabelStyle = New NDataLabelStyle(True)
            m_FunnelSeries.DataLabelStyle.VertAlign = ENVerticalAlignment.Center

            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 funnelShapeCombo As NComboBox = New NComboBox()
            funnelShapeCombo.Items.FillFromEnum(Of ENFunnelShape)()
            funnelShapeCombo.SelectedIndexChanged += AddressOf OnFunnelShapeComboSelectedIndexChanged
            funnelShapeCombo.SelectedIndex = CInt(ENFunnelShape.Trapezoid)
            stack.Add(NPairBox.Create("Funnel Shape:", funnelShapeCombo))

            Dim labelAligmentModeCombo As NComboBox = New NComboBox()
            labelAligmentModeCombo.Items.FillFromEnum(Of ENFunnelLabelMode)()
            labelAligmentModeCombo.SelectedIndexChanged += AddressOf OnLabelAligmentModeComboSelectedIndexChanged
            labelAligmentModeCombo.SelectedIndex = CInt(ENFunnelLabelMode.Center)
            stack.Add(NPairBox.Create("Label Alignment:", labelAligmentModeCombo))

            Dim labelArrowLengthUpDown As NNumericUpDown = New NNumericUpDown()
            labelArrowLengthUpDown.Value = m_FunnelSeries.LabelArrowLength
            labelArrowLengthUpDown.ValueChanged += AddressOf OnLabelArrowLengthUpDownValueChanged
            stack.Add(NPairBox.Create("Label Arrow Length:", labelArrowLengthUpDown))

            Dim pointGapUpDown As NNumericUpDown = New NNumericUpDown()
            pointGapUpDown.Value = m_FunnelSeries.PointGapPercent
            pointGapUpDown.ValueChanged += AddressOf OnPointGapUpDownValueChanged
            stack.Add(NPairBox.Create("Point Gap Percent:", pointGapUpDown))

            Dim neckHeightPercentUpDown As NNumericUpDown = New NNumericUpDown()
            neckHeightPercentUpDown.Value = m_FunnelSeries.NeckHeightPercent
            neckHeightPercentUpDown.ValueChanged += AddressOf OnNeckHeightPercentUpDownValueChanged
            stack.Add(NPairBox.Create("Neck Height Percent:", neckHeightPercentUpDown))

            Dim neckWidthPercentUpDown As NNumericUpDown = New NNumericUpDown()
            neckWidthPercentUpDown.Value = m_FunnelSeries.NeckWidthPercent
            neckWidthPercentUpDown.ValueChanged += AddressOf OnNeckWidthPercentUpDownValueChanged
            stack.Add(NPairBox.Create("Neck Width Percent:", neckWidthPercentUpDown))

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

This example demonstrates how to create a standard funnel chart.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Funnel Series", "https://www.nevron.com/docs/openvision/funnel-chart-series.html"), ("Funnel Chart", "https://www.nevron.com/docs/openvision/funnel-chart.html")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" Private Sub OnLabelArrowLengthUpDownValueChanged(arg As NValueChangeEventArgs) m_FunnelSeries.LabelArrowLength = CType(arg.TargetNode, NNumericUpDown).Value End Sub Private Sub OnLabelAligmentModeComboSelectedIndexChanged(arg As NValueChangeEventArgs) m_FunnelSeries.LabelMode = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENFunnelLabelMode) End Sub Private Sub OnPointGapUpDownValueChanged(arg As NValueChangeEventArgs) m_FunnelSeries.PointGapPercent = CType(arg.TargetNode, NNumericUpDown).Value End Sub Private Sub OnFunnelShapeComboSelectedIndexChanged(arg As NValueChangeEventArgs) m_FunnelSeries.Shape = CType(CType(arg.TargetNode, NComboBox).SelectedIndex, ENFunnelShape) End Sub Private Sub OnNeckHeightPercentUpDownValueChanged(arg As NValueChangeEventArgs) m_FunnelSeries.NeckHeightPercent = CType(arg.TargetNode, NNumericUpDown).Value End Sub Private Sub OnNeckWidthPercentUpDownValueChanged(arg As NValueChangeEventArgs) m_FunnelSeries.NeckWidthPercent = CType(arg.TargetNode, NNumericUpDown).Value End Sub #End Region #Region "Fields" Private m_FunnelSeries As NFunnelSeries #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 Funnel Example for WinForms Solution

Related Documentation Links