This example demonstrates how to create a standard point chart.

| 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.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NStandardPointExample";
// 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 Point";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);
// add interlace stripe
NLinearScale linearScale = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// setup point series
m_Point = new NPointSeries();
//m_Point.DataLabelStyle.ArrowLength = 20;
m_Point.Name = "Point Series";
m_Point.InflateMargins = true;
m_Point.DataLabelStyle = new NDataLabelStyle(false);
m_Point.DataPoints.Add(new NPointDataPoint(23, "Item1"));
m_Point.DataPoints.Add(new NPointDataPoint(67, "Item2"));
m_Point.DataPoints.Add(new NPointDataPoint(78, "Item3"));
m_Point.DataPoints.Add(new NPointDataPoint(12, "Item4"));
m_Point.DataPoints.Add(new NPointDataPoint(56, "Item5"));
m_Point.DataPoints.Add(new NPointDataPoint(43, "Item6"));
m_Point.DataPoints.Add(new NPointDataPoint(37, "Item7"));
m_Point.DataPoints.Add(new NPointDataPoint(51, "Item8"));
m_Point.Fill = new NColorFill(NColor.Red);
m_Chart.Series.Add(m_Point);
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints));
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
NCheckBox inflateMarginsCheckBox = new NCheckBox();
inflateMarginsCheckBox.CheckedChanged += OnInflateMarginsCheckBoxCheckedChanged;
stack.Add(NPairBox.Create("Inflate Margins: ", inflateMarginsCheckBox));
NCheckBox verticalAxisRoundToTick = new NCheckBox();
verticalAxisRoundToTick.CheckedChanged += OnverticalAxisRoundToTickCheckedChanged;
stack.Add(NPairBox.Create("Left Axis Round To Tick: ", verticalAxisRoundToTick));
NNumericUpDown pointSizeNumericUpDown = new NNumericUpDown();
pointSizeNumericUpDown.ValueChanged += OnPointSizeNumericUpDownValueChanged;
stack.Add(NPairBox.Create("Point Size: ", pointSizeNumericUpDown));
NComboBox pointShapeComboBox = new NComboBox();
pointShapeComboBox.Items.FillFromEnum();
pointShapeComboBox.SelectedIndexChanged += OnPointShapeComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Point Shape: ", pointShapeComboBox));
return group;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create a standard point chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Point Series", "https://www.nevron.com/docs/openvision/point-chart-series.html"),
("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
void OnPointShapeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Point.Shape = (ENPointShape3D)(arg.TargetNode as NComboBox).SelectedIndex;
}
void OnPointSizeNumericUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Point.Size = (arg.TargetNode as NNumericUpDown).Value;
}
void OnverticalAxisRoundToTickCheckedChanged(NValueChangeEventArgs arg)
{
NLinearScale linearScale = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
if (linearScale != null)
{
if ((arg.TargetNode as NCheckBox).Checked)
{
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;
linearScale.InflateViewRangeBegin = true;
linearScale.InflateViewRangeEnd = true;
}
else
{
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.Logical;
}
}
}
void OnInflateMarginsCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_Point.InflateMargins = (arg.TargetNode as NCheckBox).Checked;
}
#endregion
#region Fields
NPointSeries m_Point;
NCartesianChart m_Chart;
#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.Wpf
Class MainWindow
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Title = "NOV WPF - NStandardPointExample"
' 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)
Content = 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 = "Standard Point"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear)
' add interlace stripe
Dim linearScale As NLinearScale = TryCast(m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale, NLinearScale)
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(ENNamedColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
linearScale.Strips.Add(strip)
' setup point series
m_Point = New NPointSeries()
'm_Point.DataLabelStyle.ArrowLength = 20;
m_Point.Name = "Point Series"
m_Point.InflateMargins = True
m_Point.DataLabelStyle = New NDataLabelStyle(False)
m_Point.DataPoints.Add(New NPointDataPoint(23, "Item1"))
m_Point.DataPoints.Add(New NPointDataPoint(67, "Item2"))
m_Point.DataPoints.Add(New NPointDataPoint(78, "Item3"))
m_Point.DataPoints.Add(New NPointDataPoint(12, "Item4"))
m_Point.DataPoints.Add(New NPointDataPoint(56, "Item5"))
m_Point.DataPoints.Add(New NPointDataPoint(43, "Item6"))
m_Point.DataPoints.Add(New NPointDataPoint(37, "Item7"))
m_Point.DataPoints.Add(New NPointDataPoint(51, "Item8"))
m_Point.Fill = New NColorFill(NColor.Red)
m_Chart.Series.Add(m_Point)
chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints))
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim inflateMarginsCheckBox As NCheckBox = New NCheckBox()
inflateMarginsCheckBox.CheckedChanged += AddressOf OnInflateMarginsCheckBoxCheckedChanged
stack.Add(NPairBox.Create("Inflate Margins: ", inflateMarginsCheckBox))
Dim verticalAxisRoundToTick As NCheckBox = New NCheckBox()
verticalAxisRoundToTick.CheckedChanged += AddressOf OnverticalAxisRoundToTickCheckedChanged
stack.Add(NPairBox.Create("Left Axis Round To Tick: ", verticalAxisRoundToTick))
Dim pointSizeNumericUpDown As NNumericUpDown = New NNumericUpDown()
pointSizeNumericUpDown.ValueChanged += AddressOf OnPointSizeNumericUpDownValueChanged
stack.Add(NPairBox.Create("Point Size: ", pointSizeNumericUpDown))
Dim pointShapeComboBox As NComboBox = New NComboBox()
pointShapeComboBox.Items.FillFromEnum(Of ENPointShape3D)()
pointShapeComboBox.SelectedIndexChanged += AddressOf OnPointShapeComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Point Shape: ", pointShapeComboBox))
Return group
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a standard point chart.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Point Series", "https://www.nevron.com/docs/openvision/point-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnPointShapeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_Point.Shape = CType(TryCast(arg.TargetNode, NComboBox).SelectedIndex, ENPointShape3D)
End Sub
Private Sub OnPointSizeNumericUpDownValueChanged(arg As NValueChangeEventArgs)
m_Point.Size = TryCast(arg.TargetNode, NNumericUpDown).Value
End Sub
Private Sub OnverticalAxisRoundToTickCheckedChanged(arg As NValueChangeEventArgs)
Dim linearScale As NLinearScale = TryCast(m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale, NLinearScale)
If linearScale IsNot Nothing Then
If TryCast(arg.TargetNode, NCheckBox).Checked Then
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick
linearScale.InflateViewRangeBegin = True
linearScale.InflateViewRangeEnd = True
Else
linearScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.Logical
End If
End If
End Sub
Private Sub OnInflateMarginsCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_Point.InflateMargins = TryCast(arg.TargetNode, NCheckBox).Checked
End Sub
#End Region
#Region "Fields"
Private m_Point As NPointSeries
Private m_Chart As NCartesianChart
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class