The example demonstrates the capabilities of the heat map to display labels at each contour line.

| 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 - NContourLabelsExample";
// 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 = "Contour Chart";
// configure chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);
m_HeatMap = new NHeatMapSeries();
chart.Series.Add(m_HeatMap);
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) });
// make sure contour labels are visible
m_HeatMap.ContourLabelStyle.Visible = true;
m_HeatMap.ContourDisplayMode = ENContourDisplayMode.Contour;
m_HeatMap.LegendView.Mode = ENSeriesLegendMode.SeriesLogic;
m_HeatMap.LegendView.Format = "";
GenerateData();
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NCheckBox showContourLabelsCheckBox = new NCheckBox();
showContourLabelsCheckBox.CheckedChanged += OnShowContourLabelsCheckBoxCheckedChanged;
showContourLabelsCheckBox.Checked = true;
stack.Add(NPairBox.Create("Show Contour Labels:", showContourLabelsCheckBox));
NCheckBox allowLabelsToFlipCheckBox = new NCheckBox();
allowLabelsToFlipCheckBox.CheckedChanged += AllowLabelsToFlipCheckBoxCheckedChanged;
allowLabelsToFlipCheckBox.Checked = false;
stack.Add(NPairBox.Create("Allow Labels To Flip:", allowLabelsToFlipCheckBox));
NCheckBox showLabelBackgroundCheckBox = new NCheckBox();
showLabelBackgroundCheckBox.CheckedChanged += OnShowLabelBackgroundCheckBoxCheckedChanged;
showLabelBackgroundCheckBox.Checked = true;
stack.Add(NPairBox.Create("Show Label Background:", showLabelBackgroundCheckBox));
NCheckBox clipContourCheckBox = new NCheckBox();
clipContourCheckBox.CheckedChanged += OnClipContourCheckBoxCheckedChanged;
clipContourCheckBox.Checked = true;
stack.Add(NPairBox.Create("Clip Contour:", clipContourCheckBox));
NNumericUpDown labelDistanceUpDown = new NNumericUpDown();
labelDistanceUpDown.ValueChanged += OnLabelDistanceUpDownValueChanged;
labelDistanceUpDown.Value = 80;
stack.Add(NPairBox.Create("Label Distance:", labelDistanceUpDown));
return boxGroup;
}
private void AllowLabelsToFlipCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.AllowLabelToFlip = (bool)arg.NewValue;
}
private void OnLabelDistanceUpDownValueChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.LabelDistance = (double)arg.NewValue;
}
private void OnClipContourCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.ClipContour = (bool)arg.NewValue;
}
private void OnShowLabelBackgroundCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.TextStyle.Background.Visible = (bool)arg.NewValue;
}
private void OnAllowLabelsCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.AllowLabelToFlip = (bool)arg.NewValue;
}
private void OnShowContourLabelsCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_HeatMap.ContourLabelStyle.Visible = (bool)arg.NewValue;
}
public string GetExampleDescription()
{
return @"The example demonstrates the capabilities of the heat map to display labels at each contour line.
";
}
///
/// 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"),
("Series Label Layout", "https://www.nevron.com/docs/openvision/chart-series-label-layout.html"),
("Series Labels Appearance", "https://www.nevron.com/docs/openvision/chart-series-labels-appearance.html"),
("Label Formatting", "https://www.nevron.com/docs/openvision/chart-label-formatting.html"),
("chart-palettes", "https://www.nevron.com/docs/openvision/chart-palettes.html"),
};
}
#endregion
#region Implementation
///
///
///
private void GenerateData()
{
NHeatMapData data = m_HeatMap.Data;
int GridStepX = 300;
int GridStepY = 300;
data.Size = new NSizeI(GridStepX, GridStepY);
const double dIntervalX = 10.0;
const double dIntervalZ = 10.0;
double dIncrementX = (dIntervalX / GridStepX);
double dIncrementZ = (dIntervalZ / GridStepY);
double y, x, z;
z = -(dIntervalZ / 2);
for (int col = 0; col < GridStepX; col++, z += dIncrementZ)
{
x = -(dIntervalX / 2);
for (int row = 0; row < GridStepY; row++, x += dIncrementX)
{
y = 10 - Math.Sqrt((x * x) + (z * z) + 2);
y += 3.0 * Math.Sin(x) * Math.Cos(z);
data.SetValue(row, col, y);
}
}
}
#endregion
#region Event Handlers
#endregion
#region Fields
NHeatMapSeries m_HeatMap;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Imports System
Public Class Form1
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Text = "NOV WinForms - NContourLabelsExample"
' Create the NOV example and its controls
Dim exampleContent As NWidget = CreateExampleContent()
Dim exampleControls As NWidget = CreateExampleControls()
If Not exampleControls Is Nothing Then
exampleControls.PreferredWidth = 300
End If
' Place the example and its controls in a pair box
Dim pairBox As NPairBox = 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
Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
host.Dock = DockStyle.Fill
Controls.Add(host)
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
Dim chartView = chartViewWithCommandBars.View
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)
' configure title
chartView.Surface.Titles(0).Text = "Contour Chart"
' configure chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear)
m_HeatMap = New NHeatMapSeries()
chart.Series.Add(m_HeatMap)
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)})
' make sure contour labels are visible
m_HeatMap.ContourLabelStyle.Visible = True
m_HeatMap.ContourDisplayMode = ENContourDisplayMode.Contour
m_HeatMap.LegendView.Mode = ENSeriesLegendMode.SeriesLogic
m_HeatMap.LegendView.Format = ""
GenerateData()
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim showContourLabelsCheckBox As NCheckBox = New NCheckBox()
showContourLabelsCheckBox.CheckedChanged += AddressOf OnShowContourLabelsCheckBoxCheckedChanged
showContourLabelsCheckBox.Checked = True
stack.Add(NPairBox.Create("Show Contour Labels:", showContourLabelsCheckBox))
Dim allowLabelsToFlipCheckBox As NCheckBox = New NCheckBox()
allowLabelsToFlipCheckBox.CheckedChanged += AddressOf AllowLabelsToFlipCheckBoxCheckedChanged
allowLabelsToFlipCheckBox.Checked = False
stack.Add(NPairBox.Create("Allow Labels To Flip:", allowLabelsToFlipCheckBox))
Dim showLabelBackgroundCheckBox As NCheckBox = New NCheckBox()
showLabelBackgroundCheckBox.CheckedChanged += AddressOf OnShowLabelBackgroundCheckBoxCheckedChanged
showLabelBackgroundCheckBox.Checked = True
stack.Add(NPairBox.Create("Show Label Background:", showLabelBackgroundCheckBox))
Dim clipContourCheckBox As NCheckBox = New NCheckBox()
clipContourCheckBox.CheckedChanged += AddressOf OnClipContourCheckBoxCheckedChanged
clipContourCheckBox.Checked = True
stack.Add(NPairBox.Create("Clip Contour:", clipContourCheckBox))
Dim labelDistanceUpDown As NNumericUpDown = New NNumericUpDown()
labelDistanceUpDown.ValueChanged += AddressOf OnLabelDistanceUpDownValueChanged
labelDistanceUpDown.Value = 80
stack.Add(NPairBox.Create("Label Distance:", labelDistanceUpDown))
Return boxGroup
End Function
Private Sub AllowLabelsToFlipCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.AllowLabelToFlip = CBool(arg.NewValue)
End Sub
Private Sub OnLabelDistanceUpDownValueChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.LabelDistance = CDbl(arg.NewValue)
End Sub
Private Sub OnClipContourCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.ClipContour = CBool(arg.NewValue)
End Sub
Private Sub OnShowLabelBackgroundCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.TextStyle.Background.Visible = CBool(arg.NewValue)
End Sub
Private Sub OnAllowLabelsCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.AllowLabelToFlip = CBool(arg.NewValue)
End Sub
Private Sub OnShowContourLabelsCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_HeatMap.ContourLabelStyle.Visible = CBool(arg.NewValue)
End Sub
Public Function GetExampleDescription() As String
Return "The example demonstrates the capabilities of the heat map to display labels at each contour line.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Heat Map Series", "https://www.nevron.com/docs/openvision/heat-map-chart-series.html"), ("Series Label Layout", "https://www.nevron.com/docs/openvision/chart-series-label-layout.html"), ("Series Labels Appearance", "https://www.nevron.com/docs/openvision/chart-series-labels-appearance.html"), ("Label Formatting", "https://www.nevron.com/docs/openvision/chart-label-formatting.html"), ("chart-palettes", "https://www.nevron.com/docs/openvision/chart-palettes.html")}
End Function
#End Region
#Region "Implementation"
'''
'''
'''
Private Sub GenerateData()
Dim data = m_HeatMap.Data
Dim GridStepX = 300
Dim GridStepY = 300
data.Size = New NSizeI(GridStepX, GridStepY)
Const dIntervalX = 10.0
Const dIntervalZ = 10.0
Dim dIncrementX = dIntervalX / GridStepX
Dim dIncrementZ = dIntervalZ / GridStepY
Dim y, x, z As Double
z = -(dIntervalZ / 2)
Dim col = 0
While col < GridStepX
x = -(dIntervalX / 2)
Dim row = 0
While row < GridStepY
y = 10 - Math.Sqrt(x * x + z * z + 2)
y += 3.0 * Math.Sin(x) * Math.Cos(z)
data.SetValue(row, col, y)
row += 1
x += dIncrementX
End While
col += 1
z += dIncrementZ
End While
End Sub
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_HeatMap As NHeatMapSeries
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class