This example demonstrates how to create a standard area chart.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Chart.Tools;
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 - NStepAreaExample";
// 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 = "Step Area";
// configure chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
// setup X axis
NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
scaleX.InflateContentRange = false;
scaleX.MajorTickMode = ENMajorTickMode.AutoMaxCount;
scaleX.DisplayDataPointsBetweenTicks = false;
scaleX.Labels.Visible = false;
for (int i = 0; i < monthLetters.Length; i++)
{
scaleX.CustomLabels.Add(new NCustomValueLabel(i, monthLetters[i]));
}
// add interlaced stripe for Y axis
NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
stripStyle.Interlaced = true;
NLinearScale scaleY = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;
scaleY.Strips.Add(stripStyle);
// setup area series
m_Area = new NAreaSeries();
m_Area.OriginMode = ENSeriesOriginMode.CustomOrigin;
m_Area.CustomOrigin = 18;
chart.Series.Add(m_Area);
m_Area.Name = "Area Series";
m_Area.Stroke = new NStroke(1, NColor.Black);
NDataLabelStyle dataLabelStyle = new NDataLabelStyle();
dataLabelStyle.Visible = true;
dataLabelStyle.Format = "";
m_Area.DataLabelStyle = dataLabelStyle;
for (int i = 0; i < monthValues.Length; i++)
{
m_Area.DataPoints.Add(new NAreaDataPoint(monthValues[i]));
}
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NComboBox originModeComboBox = new NComboBox();
originModeComboBox.Items.FillFromEnum();
originModeComboBox.SelectedIndexChanged += OnOriginModeComboBoxSelectedIndexChanged;
originModeComboBox.SelectedIndex = (int)m_Area.OriginMode;
stack.Add(NPairBox.Create("Origin Mode: ", originModeComboBox));
NNumericUpDown customOriginUpDown = new NNumericUpDown();
customOriginUpDown.ValueChanged += OnCustomOriginUpDownValueChanged;
stack.Add(NPairBox.Create("Custom Origin: ", customOriginUpDown));
customOriginUpDown.Value = m_Area.CustomOrigin;
NComboBox areaSegmentModeComboBox = new NComboBox();
areaSegmentModeComboBox.Items.FillFromEnum();
areaSegmentModeComboBox.SelectedIndexChanged += OnStepAreaSegmentModeComboBoxIndexChanged;
stack.Add(NPairBox.Create("Segment Mode: ", areaSegmentModeComboBox));
areaSegmentModeComboBox.SelectedIndex = (int)ENAreaSegmentMode.HVHStep;
NCheckBox showDropLinesCheckBox = new NCheckBox();
showDropLinesCheckBox.CheckedChanged += OnShowDropLinesCheckBoxCheckedChanged;
stack.Add(NPairBox.Create("Show Droplines: ", showDropLinesCheckBox));
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create a standard area chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Area Series", "https://www.nevron.com/docs/openvision/area-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 OnCustomOriginUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Area.CustomOrigin = (double)((NNumericUpDown)arg.TargetNode).Value;
}
void OnOriginModeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_Area.OriginMode = (ENSeriesOriginMode)((NComboBox)arg.TargetNode).SelectedIndex;
}
void OnStepAreaSegmentModeComboBoxIndexChanged(NValueChangeEventArgs arg)
{
m_Area.SegmentMode = (ENAreaSegmentMode)((NComboBox)arg.TargetNode).SelectedIndex;
}
private void OnShowDropLinesCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_Area.ShowDropLines = (bool)arg.NewValue;
}
#endregion
#region Fields
NAreaSeries m_Area;
#endregion
#region Static Methods
#endregion
#region Constants
internal static readonly double[] monthValues = new double[] { 16, 19, 16, 15, 18, 19, 24, 21, 22, 17, 19, 15 };
internal static readonly string[] monthLetters = new string[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" };
#endregion
#region Nested Types
#endregion
}
}