Point Droplines 2D 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.

Point Droplines 2D Example for Blazor Description

This example demonstrates how to enable point drop lines.


Point Drop Lines Example

C# Point Droplines 2D Example Code for Nevron Chart for Blazor
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 - NPointDropLinesExample";

			// 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 = "Point Drop Lines";

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

			m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // setup X axis
            NLinearScale scaleX = new NLinearScale();
			scaleX.MajorGridLines = new NScaleGridLines();
            scaleX.MajorGridLines.Visible = true;
			scaleX.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
			m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = scaleX;

			// setup Y axis
			NLinearScale scaleY = new NLinearScale();
			scaleY.MajorGridLines = new NScaleGridLines();
            scaleY.MajorGridLines.Visible = true;
			scaleY.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
			m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale = scaleY;

            // add interlace stripe to the Y axis
            NScaleStrip stripStyleY = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
            stripStyleY.Interlaced = true;
            stripStyleY.SetShowAtWall(ENChartWall.Back, true);
            stripStyleY.SetShowAtWall(ENChartWall.Left, true);
            scaleY.Strips.Add(stripStyleY);

            // add a point series
            m_Point = new NPointSeries();
			m_Point.Name = "Point Series";
			m_Point.DataLabelStyle = new NDataLabelStyle(false);
			m_Point.Fill = new NColorFill(NColor.DarkOrange);
			m_Point.Size = 10;
			m_Point.Shape = ENPointShape3D.Ellipse;
			m_Point.UseXValues = true;
			m_Chart.Series.Add(m_Point);

            for (int i = 0; i < 360; i += 5)
            {
                double value = Math.Sin(NAngle.Degree2Rad * i);

                m_Point.DataPoints.Add(new NPointDataPoint(i, value));
            }

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

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
            NCheckBox showVerticalDropLinesCheckBox = new NCheckBox("Show Vertical Drop Lines");
            showVerticalDropLinesCheckBox.CheckedChanged += OnShowVerticalDropLinesCheckBoxCheckedChanged;
            stack.Add(showVerticalDropLinesCheckBox);

            NComboBox verticalDropLinesOriginModeCombo = new NComboBox();
            verticalDropLinesOriginModeCombo.Items.FillFromEnum();
            verticalDropLinesOriginModeCombo.SelectedIndexChanged += OnVerticalDropLinesOriginModeComboSelectedIndexChanged;
            verticalDropLinesOriginModeCombo.SelectedIndex = (int)ENDropLineOriginMode.CustomValue;
            stack.Add(NPairBox.Create("Origin Mode:", verticalDropLinesOriginModeCombo));

            NNumericUpDown verticalDropLinesOriginUpDown = new NNumericUpDown();
            verticalDropLinesOriginUpDown.ValueChanged += OnVerticalDropLinesOriginUpDownValueChanged;
            verticalDropLinesOriginUpDown.Value = 180.0;
            stack.Add(NPairBox.Create("Origin", verticalDropLinesOriginUpDown));

            NCheckBox showHorizontalDropLinesCheckBox = new NCheckBox("Show Horizontal Drop Lines");
            showHorizontalDropLinesCheckBox.CheckedChanged += OnShowHorizontalDropLinesCheckBoxCheckedChanged;
            showHorizontalDropLinesCheckBox.Checked = true;
            stack.Add(showHorizontalDropLinesCheckBox);

            NComboBox horizontalDropLinesOriginModeCombo = new NComboBox();
            horizontalDropLinesOriginModeCombo.Items.FillFromEnum();
            horizontalDropLinesOriginModeCombo.SelectedIndexChanged += OnHorizontalDropLinesOriginModeComboSelectedIndexChanged;
            horizontalDropLinesOriginModeCombo.SelectedIndex = (int)ENDropLineOriginMode.CustomValue;
            stack.Add(NPairBox.Create("Origin Mode:", horizontalDropLinesOriginModeCombo));

            NNumericUpDown horizontalDropLinesOriginUpDown = new NNumericUpDown();
            horizontalDropLinesOriginUpDown.ValueChanged +=OnHorizontalDropLinesOriginUpDownValueChanged;
            stack.Add(NPairBox.Create("Origin:", horizontalDropLinesOriginUpDown));

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

This example demonstrates how to enable point drop lines.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Point Series", "https://www.nevron.com/docs/openvision/point-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), }; } #endregion #region Implementation #endregion #region Event Handlers void OnHorizontalDropLinesOriginUpDownValueChanged(NValueChangeEventArgs arg) { m_Point.HorizontalDropLineOrigin = ((NNumericUpDown)arg.TargetNode).Value; } void OnVerticalDropLinesOriginUpDownValueChanged(NValueChangeEventArgs arg) { m_Point.VerticalDropLineOrigin = ((NNumericUpDown)arg.TargetNode).Value; } void OnHorizontalDropLinesOriginModeComboSelectedIndexChanged(NValueChangeEventArgs arg) { m_Point.HorizontalDropLineOriginMode = (ENDropLineOriginMode)((NComboBox)arg.TargetNode).SelectedIndex; } void OnVerticalDropLinesOriginModeComboSelectedIndexChanged(NValueChangeEventArgs arg) { m_Point.VerticalDropLineOriginMode = (ENDropLineOriginMode)((NComboBox)arg.TargetNode).SelectedIndex; } void OnShowHorizontalDropLinesCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_Point.ShowHorizontalDropLines = ((NCheckBox)arg.TargetNode).Checked; } void OnShowVerticalDropLinesCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_Point.ShowVerticalDropLines = ((NCheckBox)arg.TargetNode).Checked; } #endregion #region Fields NPointSeries m_Point; NCartesianChart m_Chart; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Point Droplines 2D Example for Blazor Solution

Related Documentation Links