This example demonstrates how to create a combo chart consisting of a line chart and several high-low series to represent a fan 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;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NFanChartExample";
// 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();
// create the chart view
NChartView chartView = chartViewWithCommandBars.View;
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);
// Configure title
chartView.Surface.Titles[0].Text = "Fan Chart";
// Get cartesian chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
// add interlace stripe
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);
NColor[] palette = NChartPalette.GetColors(ENChartPalette.Bright);
// Create a line series (main projection/forecast)
NLineSeries lineSeries = new NLineSeries();
chart.Series.Add(lineSeries);
lineSeries.Name = "Projection";
lineSeries.InflateMargins = true;
lineSeries.Stroke = new NStroke(3, NColor.Black);
lineSeries.DataLabelStyle = new NDataLabelStyle(false);
NHighLowSeries[] confidenceIntervals = new NHighLowSeries[5];
float confidenceStep = 10f;
// Create a range series (uncertainty band)
for (int i = 0; i < confidenceIntervals.Length; i++)
{
NHighLowSeries highLowSeries = new NHighLowSeries();
chart.Series.Insert(0, highLowSeries);
confidenceIntervals[i] = highLowSeries;
highLowSeries.Name = "Confidence Interval " + (i * confidenceStep + confidenceStep).ToString() + "%";
float baseAlpha = 0.3f;
highLowSeries.HighFill = new NColorFill(NColor.FromColor(palette[i], baseAlpha - baseAlpha * (float)i / (float)confidenceIntervals.Length));
highLowSeries.LowFill = new NColorFill(NColor.FromColor(palette[i], baseAlpha - baseAlpha * (float)i / (float)confidenceIntervals.Length));
highLowSeries.Stroke = new NStroke(0, NColor.White); // no outline
}
// Sample data
double[] baseValues = { 10, 12, 15, 18, 22, 26, 30, 34, 38 };
Random random = new Random();
for (int i = 0; i < baseValues.Length; i++)
{
lineSeries.DataPoints.Add(new NLineDataPoint(baseValues[i]));
double baseValue = baseValues[i];
double lowBaseValue = baseValues[i];
double highBaseValue = baseValues[i];
for (int j = 0; j < confidenceIntervals.Length; j++)
{
lowBaseValue += -baseValues[i] * random.NextDouble() * confidenceStep / 100;
highBaseValue += baseValues[i] * random.NextDouble() * confidenceStep / 100;
confidenceIntervals[j].DataPoints.Add(new NHighLowDataPoint(highBaseValue, lowBaseValue));
}
}
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 a line chart and several high-low series to represent a fan chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Range Series", "https://www.nevron.com/docs/openvision/range-chart-series.html"),
("Line Series", "https://www.nevron.com/docs/openvision/line-chart-series.html"),
("Cartesian Chart", "https://www.nevron.com/docs/openvision/cartesian-chart.html"),
("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"),
("Overview", "https://www.nevron.com/docs/openvision/chart-legeng-overview.html"),
};
}
#endregion
#region Implementation
private NComboBox CreateLegendFormatCombo()
{
NComboBox comboBox = new NComboBox();
NComboBoxItem item = new NComboBoxItem("Value and Label");
item.Tag = "