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.
Data Binding Example for WinForms Description
This example demonstrates how bind the chart data points to a data source.
Once the data points are bound, they will be automatically updated when the data source changes.
C# Data Binding Example Code for Nevron Chart for WinForms
Language: C#
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Data;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Grid;
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 - NChartDataBindingExample";
// 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()
{
// create a dummy data source, which to share between the grid and the chart
m_MemoryDataTable = new NMemoryDataTable(
new NFieldInfo("Value", typeof(double), false),
new NFieldInfo("XValue", typeof(double), false),
new NFieldInfo("Label", typeof(string), false));
Random rnd = new Random();
for (int i = 0; i < 15; i++)
{
m_MemoryDataTable.AddRow(
rnd.Next(0, 100),
rnd.Next(0, 100),
"Label: " + i.ToString());
}
// create cartesian chart view
NChartViewWithCommandBars chartViewWithCommandBars = new NChartViewWithCommandBars();
NChartView chartView = chartViewWithCommandBars.View;
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);
// get chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
// switch X axis in linear scale
chart.Axes[ENCartesianAxis.PrimaryX].Scale = new NLinearScale();
// add interlaced stripe for Y axis
NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);
// create a point series to show the data source values
NPointSeries pointSeries = new NPointSeries();
chart.Series.Add(pointSeries);
pointSeries.UseXValues = true;
pointSeries.ValueFormatter = new NNumericValueFormatter("0.00");
pointSeries.DataLabelStyle = new NDataLabelStyle();
pointSeries.DataLabelStyle.Visible = true;
pointSeries.DataLabelStyle.Format = "
Download a fully functional C# (.cs) Data Binding Example for WinForms Solution
VB.NET Data Binding Example Code for Nevron Chart for WinForms
Language: VB.NET
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Data
Imports Nevron.Nov.DataStructures
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Grid
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 - NChartDataBindingExample"
' 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
' create a dummy data source, which to share between the grid and the chart
m_MemoryDataTable = New NMemoryDataTable(New NFieldInfo("Value", GetType(Double), False), New NFieldInfo("XValue", GetType(Double), False), New NFieldInfo("Label", GetType(String), False))
Dim rnd As Random = New Random()
For i = 0 To 14
m_MemoryDataTable.AddRow(rnd.Next(0, 100), rnd.Next(0, 100), "Label: " & i.ToString())
Next
' create cartesian chart view
Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
Dim chartView = chartViewWithCommandBars.View
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)
' get chart
Dim chart = CType(chartView.Surface.Charts(0), NCartesianChart)
' switch X axis in linear scale
chart.Axes(ENCartesianAxis.PrimaryX).Scale = New NLinearScale()
' add interlaced stripe for Y axis
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
chart.Axes(ENCartesianAxis.PrimaryY).Scale.Strips.Add(strip)
' create a point series to show the data source values
Dim pointSeries As NPointSeries = New NPointSeries()
chart.Series.Add(pointSeries)
pointSeries.UseXValues = True
pointSeries.ValueFormatter = New NNumericValueFormatter("0.00")
pointSeries.DataLabelStyle = New NDataLabelStyle()
pointSeries.DataLabelStyle.Visible = True
pointSeries.DataLabelStyle.Format = "
Download a fully functional VB.NET (.vb) Data Binding Example for WinForms Solution