Standard Heat Map 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.

Standard Heat Map Example for Blazor Description

This example demonstrates how to create a standard heat map chart.


Standard Heat Map Example

C# Standard Heat Map 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 - NStandardHeatMapExample";

			// 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 = "Standard Heat Map";

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

            m_HeatMap = new NHeatMapSeries();
            chart.Series.Add(m_HeatMap);

            NHeatMapData data = m_HeatMap.Data;

            m_HeatMap.Palette = new NColorValuePalette( new NColorValuePair[] { new NColorValuePair(0.0, NColor.Purple),
                                                        new NColorValuePair(1.5, NColor.MediumSlateBlue),
                                                        new NColorValuePair(3.0, NColor.CornflowerBlue),
                                                        new NColorValuePair(4.5, NColor.LimeGreen),
                                                        new NColorValuePair(6.0, NColor.LightGreen),
                                                        new NColorValuePair(7.5, NColor.Yellow),
                                                        new NColorValuePair(9.0, NColor.Orange),
                                                        new NColorValuePair(10.5, NColor.Red) });

			int gridSizeX = 100;
			int gridSizeY = 100;
			data.Size = new NSizeI(gridSizeX, gridSizeY);
			double y, x, z;

			const double dIntervalX = 10.0;
			const double dIntervalZ = 10.0;
			double dIncrementX = (dIntervalX / gridSizeX);
			double dIncrementZ = (dIntervalZ / gridSizeY);

			z = -(dIntervalZ / 2);

			for (int j = 0; j < gridSizeY; j++, z += dIncrementZ)
			{
				x = -(dIntervalX / 2);

				for (int i = 0; i < gridSizeX; i++, x += dIncrementX)
				{
					y = 10 - Math.Sqrt((x * x) + (z * z) + 2);
					y += 3.0 * Math.Sin(x) * Math.Cos(z);

					data.SetValue(i, j, y);
				}
			}

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);

            NCheckBox smoothPaletteCheckBox = new NCheckBox("Smooth Palette");
            smoothPaletteCheckBox.CheckedChanged += OnSmoothPaletteCheckBoxCheckedChanged;
            smoothPaletteCheckBox.Checked = true;
            stack.Add(smoothPaletteCheckBox);

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

This example demonstrates how to create a standard heat map chart.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Heat Map Series", "https://www.nevron.com/docs/openvision/heat-map-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("chart-palettes", "https://www.nevron.com/docs/openvision/chart-palettes.html"), ("Overview", "https://www.nevron.com/docs/openvision/chart-legeng-overview.html"), }; } #endregion #region Implementation #endregion #region Event Handlers void OnSmoothPaletteCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_HeatMap.Palette.InterpolateColors = ((NCheckBox)arg.TargetNode).Checked; } #endregion #region Fields NHeatMapSeries m_HeatMap; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Standard Heat Map Example for Blazor Solution