Scatter Funnel Example for Blazor

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

Scatter Funnel Example for Blazor Description

This example demonstrates how to create a scatter funnel chart.


Scatter Funnel Example

C# Scatter Funnel Example Code for Nevron Chart for Blazor
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 - NScatterFunnelExample";

			// 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 = "Scatter Funnel";

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

			m_FunnelSeries = new NFunnelSeries();
			m_FunnelSeries.UseXValues = true;
			m_FunnelSeries.Shape = ENFunnelShape.Rectangle;
            m_FunnelSeries.DataLabelStyle = new NDataLabelStyle(true);
			m_FunnelSeries.DataLabelStyle.VertAlign = ENVerticalAlignment.Center;

			funnelChart.Series.Add(m_FunnelSeries);

			GenerateData();

			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.Rectangle;
			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));

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

This example demonstrates how to create a scatter 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 private void GenerateData() { m_FunnelSeries.DataPoints.Clear(); double dSizeX = 100; Random random = new Random(); for (int i = 0; i < 12; i++) { m_FunnelSeries.DataPoints.Add(new NFunnelDataPoint(random.Next(100) + 1, dSizeX)); dSizeX -= random.NextDouble() * 9; } } #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; } #endregion #region Fields NFunnelSeries m_FunnelSeries; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Scatter Funnel Example for Blazor Solution

Related Documentation Links