Combo Chart 1 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.

Combo Chart 1 Example for Blazor Description

This example demonstrates how to create a combo chart consisting of two series (NOV Chart supports an unlimited number of series).


Combo Chart Example 1

C# Combo Chart 1 Example Code for Nevron Chart for Blazor
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.DataStructures;
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 - NComboChartExample1";

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

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

			m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

			// Setup the primary Y axis
			m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Title.Text = "Number of Occurences";

			// add interlace stripe
			NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
			strip.Interlaced = true;
			m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);

			// Setup the secondary Y axis
			NLinearScale scaleY2 = new NLinearScale();
			scaleY2.Labels.TextProvider = new NFormattedScaleLabelTextProvider(new NNumericValueFormatter("0%"));
			scaleY2.Title.Text = "Cumulative Percent";

			NCartesianAxis axisY2 = m_Chart.Axes[ENCartesianAxis.SecondaryY];

			axisY2.Visible = true;
			axisY2.Scale = scaleY2;
			axisY2.ViewRangeMode = ENAxisViewRangeMode.FixedRange;
			axisY2.MinViewRangeValue = 0;
			axisY2.MaxViewRangeValue = 1;

			// add the bar series
			NBarSeries bar = new NBarSeries();
			m_Chart.Series.Add(bar);
			bar.Name = "Bar Series";
			bar.DataLabelStyle = new NDataLabelStyle(false);

			// add the line series
			NLineSeries line = new NLineSeries();
			m_Chart.Series.Add(line);
			line.Name = "Cumulative %";
			line.DataLabelStyle = new NDataLabelStyle(false);

			NMarkerStyle markerStyle = new NMarkerStyle();
			markerStyle.Visible = true;
			markerStyle.Shape = ENPointShape3D.Ellipse;
			markerStyle.Size = new NSize(10, 10);
			markerStyle.Fill = new NColorFill(NColor.Orange);

			line.MarkerStyle = markerStyle;

			line.VerticalAxis = axisY2;

			// fill with random data and sort in descending order
			int count = 10;
			NList randomValues = new NList();
			Random random = new Random();
			for (int i = 0; i < count; i++)
			{
				randomValues.Add(random.Next(100, 700));
			}

			randomValues.Sort();

			for (int i = 0; i < randomValues.Count; i++)
			{
				bar.DataPoints.Add(new NBarDataPoint(randomValues[i]));
			}

			// calculate cumulative sum of the bar values
			double cs = 0;
			double[] arrCumulative = new double[count];

			for (int i = 0; i < count; i++)
			{
				cs += randomValues[i];
				arrCumulative[i] = cs;
			}

			if (cs > 0)
			{
				for (int i = 0; i < count; i++)
				{
					arrCumulative[i] /= cs;
					line.DataPoints.Add(new NLineDataPoint(arrCumulative[i]));
				}
			}

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

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
			
			return group;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create a combo chart consisting of two series (NOV Chart supports an unlimited number of series).

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Cartesian Chart", "https://www.nevron.com/docs/openvision/cartesian-chart.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("Bar Series", "https://www.nevron.com/docs/openvision/bar-chart-series.html"), ("Line Series", "https://www.nevron.com/docs/openvision/line-chart-series.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"), }; } #endregion #region Implementation private NComboBox CreateLegendFormatCombo() { NComboBox comboBox = new NComboBox(); NComboBoxItem item = new NComboBoxItem("Value and Label"); item.Tag = "

Download a fully functional C# (.cs) Combo Chart 1 Example for Blazor Solution