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

Kagi Example for Blazor Description

This example demonstrates the functionality of the kagi series.


Kagi Example

C# Kagi 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 - NKagiExample";

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

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

			chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

			NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;

			// add interlace stripe
			NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
			stripStyle.Interlaced = true;
			scaleY.Strips.Add(stripStyle);

			// setup X axis
			NPriceTimeScale priceScale = new NPriceTimeScale();
			priceScale.InnerMajorTicks.Stroke = new NStroke(0.0, NColor.Black);
			chart.Axes[ENCartesianAxis.PrimaryX].Scale = priceScale;

			// setup line break series
			m_KagiSeries = new NKagiSeries();
			m_KagiSeries.UseXValues = true;
			chart.Series.Add(m_KagiSeries);

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

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			NNumericUpDown reversalAmountUpDown = new NNumericUpDown();
			reversalAmountUpDown.Minimum = 1;
			reversalAmountUpDown.Maximum = 100;
			reversalAmountUpDown.Value = m_KagiSeries.ReversalAmount;
			reversalAmountUpDown.ValueChanged += OnReversalAmountUpDownValueChanged;
			stack.Add(NPairBox.Create("Reversal Amount:", reversalAmountUpDown));

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

This example demonstrates the functionality of the kagi series.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Chart Types Overview", "https://www.nevron.com/docs/openvision/chart-types-overview.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"), ("Stock Series", "https://www.nevron.com/docs/openvision/stock-chart-series.html"), ("Cartesian Chart", "https://www.nevron.com/docs/openvision/cartesian-chart.html"), ("DateTime Scale", "https://www.nevron.com/docs/openvision/datetime-scale.html"), }; } #endregion #region Implementation private void GenerateData(NKagiSeries KagiSeries) { NStockDataGenerator dataGenerator = new NStockDataGenerator(new NRange(50, 350), 0.002, 2); dataGenerator.Reset(); DateTime dt = DateTime.Now; for (int i = 0; i < 100; i++) { KagiSeries.DataPoints.Add(new NKagiDataPoint(NDateTimeHelpers.ToOADate(dt), dataGenerator.GetNextValue())); dt = dt.AddDays(1); } } #endregion #region Event Handlers void OnReversalAmountUpDownValueChanged(NValueChangeEventArgs arg) { m_KagiSeries.ReversalAmount = ((NNumericUpDown)arg.TargetNode).Value; } #endregion #region Fields NKagiSeries m_KagiSeries; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

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