Nevron NOV Chart for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite.
All WinForms Chart examples are also available as a stand-alone Visual Studio solution
in C# and VB.NET,
which you can download from the links below.
Combo Chart 2 Example for WinForms Description
This example demonstrates how to create a combo chart consisting of two series (NOV Chart supports an unlimited number of series).
C# Combo Chart 2 Example Code for Nevron Chart for WinForms
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 WinForms Solution
VB.NET Combo Chart 2 Example Code for Nevron Chart for WinForms
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
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 - NComboChartExample2"
' 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 = "NY Monthly Weather - Combo Chart"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
' X-axis labels
Dim months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
' Data
Dim 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}
Dim 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}
Dim 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
CType(m_Chart.Axes(ENCartesianAxis.PrimaryX).Scale, NOrdinalScale).Labels.TextProvider = New NOrdinalScaleLabelTextProvider(months)
m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale.Title.Text = "Temperature"
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale.Strips.Add(strip)
' Setup the secondary Y axis
Dim axisY2 = m_Chart.Axes(ENCartesianAxis.SecondaryY)
axisY2.Visible = True
Dim scaleY2 As NLinearScale = New NLinearScale()
scaleY2.Title.Text = "Rainfall"
axisY2.Scale = scaleY2
' Setup the third Y axis
Dim axisY3 As NCartesianAxis = New NCartesianAxis()
axisY3.Anchor = New NAutoSideDockAxisAnchor(ENCartesianAxisOrientation.Vertical, True)
m_Chart.Axes.Add(axisY3)
axisY3.Visible = True
Dim scaleY3 As NLinearScale = New NLinearScale()
scaleY3.Title.Text = "Sunshine"
axisY3.Scale = scaleY3
' add the temperature series
Dim temperatureSeries As NAreaSeries = New NAreaSeries()
m_Chart.Series.Add(temperatureSeries)
temperatureSeries.Name = "Temperature"
temperatureSeries.DataLabelStyle = New NDataLabelStyle(False)
' add reinfall series
Dim rainfallSeries As NBarSeries = New NBarSeries()
m_Chart.Series.Add(rainfallSeries)
rainfallSeries.Name = "Rainfall"
rainfallSeries.DataLabelStyle = New NDataLabelStyle(False)
rainfallSeries.VerticalAxis = axisY2
' add sunshine series
Dim sunshineSeries As NLineSeries = New NLineSeries()
m_Chart.Series.Add(sunshineSeries)
sunshineSeries.Name = "Sunshine"
sunshineSeries.DataLabelStyle = New NDataLabelStyle(False)
sunshineSeries.VerticalAxis = axisY3
For i = 0 To months.Length - 1
temperatureSeries.DataPoints.Add(New NAreaDataPoint(temperatureData(i)))
rainfallSeries.DataPoints.Add(New NBarDataPoint(rainfallData(i)))
sunshineSeries.DataPoints.Add(New NLineDataPoint(sunshineData(i)))
Next
chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series))
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Return group
End Function
Public Function GetExampleDescription() As String
Return "
This example demonstrates how to create a combo chart consisting of two series (NOV Chart supports an unlimited number of series).
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("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")}
End Function
#End Region
#Region "Implementation"
Private Function CreateLegendFormatCombo() As NComboBox
Dim comboBox As NComboBox = New NComboBox()
Dim item As NComboBoxItem = New NComboBoxItem("Value and Label")
item.Tag = ""
comboBox.Items.Add(item)
item = New NComboBoxItem("Value")
item.Tag = ""
comboBox.Items.Add(item)
item = New NComboBoxItem("Label")
item.Tag = ""
comboBox.Items.Add(item)
item = New NComboBoxItem("Size")
item.Tag = ""
comboBox.Items.Add(item)
Return comboBox
End Function
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_Chart As NCartesianChart
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class
Download a fully functional VB.NET (.vb) Combo Chart 2 Example for WinForms Solution