Combo Chart 2 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 2 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 2

C# Combo Chart 2 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 - NComboChartExample2";

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

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

            // X-axis labels
            string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            // Data
            double[] temperatureData = { 0.6, 1.3, 5.6, 11.6, 17.2, 22.2, 24.7, 24.1, 20.0, 13.7, 8.2, 2.9 };
            double[] rainfallData = { 81.2, 72.9, 97.8, 95.3, 99.1, 85.6, 96.3, 89.4, 94.5, 94.0, 85.3, 89.9 };
            double[] sunshineData = { 138.0, 153.0, 188.0, 210.0, 245.0, 280.0, 300.0, 275.0, 230.0, 190.0, 155.0, 140.0 };

			// Setup the primary Y axis
			((NOrdinalScale)(m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale)).Labels.TextProvider = new NOrdinalScaleLabelTextProvider(months);

            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Title.Text = "Temperature";
			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
			NCartesianAxis axisY2 = m_Chart.Axes[ENCartesianAxis.SecondaryY];
            axisY2.Visible = true;
            NLinearScale scaleY2 = new NLinearScale();
            scaleY2.Title.Text = "Rainfall";
            axisY2.Scale = scaleY2;

            // Setup the third Y axis
			NCartesianAxis axisY3 = new NCartesianAxis();
			axisY3.Anchor = new NAutoSideDockAxisAnchor(ENCartesianAxisOrientation.Vertical, true);
			m_Chart.Axes.Add(axisY3);
            axisY3.Visible = true;

            NLinearScale scaleY3 = new NLinearScale();
            scaleY3.Title.Text = "Sunshine";
            axisY3.Scale = scaleY3;

            // add the temperature series
            NAreaSeries temperatureSeries = new NAreaSeries();
			m_Chart.Series.Add(temperatureSeries);
			temperatureSeries.Name = "Temperature";
			temperatureSeries.DataLabelStyle = new NDataLabelStyle(false);

            // add reinfall series
            NBarSeries rainfallSeries = new NBarSeries();
            m_Chart.Series.Add(rainfallSeries);
            rainfallSeries.Name = "Rainfall";
            rainfallSeries.DataLabelStyle = new NDataLabelStyle(false);
            rainfallSeries.VerticalAxis = axisY2;

            // add sunshine series
            NLineSeries sunshineSeries = new NLineSeries();
            m_Chart.Series.Add(sunshineSeries);
            sunshineSeries.Name = "Sunshine";
            sunshineSeries.DataLabelStyle = new NDataLabelStyle(false);
			sunshineSeries.VerticalAxis = axisY3;

            for (int i = 0; i < months.Length; i++)
			{
				temperatureSeries.DataPoints.Add(new NAreaDataPoint(temperatureData[i]));
				rainfallSeries.DataPoints.Add(new NBarDataPoint(rainfallData[i]));
				sunshineSeries.DataPoints.Add(new NLineDataPoint(sunshineData[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 2 Example for Blazor Solution