Back to Devexpress

Range Area Chart

windowsforms-9976-controls-and-libraries-chart-control-series-views-2d-series-views-area-series-views-range-area-chart.md

latest7.3 KB
Original Source

Range Area Chart

  • Jul 08, 2019
  • 4 minutes to read

Short Description

The Range Area chart is represented by the RangeAreaSeriesView object, which belongs to Area Series Views. This view displays series as filled areas on a diagram, with two data points that define minimum and maximum limits. This view is useful when you need to illustrate the difference between start and end values.

A Range Area chart is shown in the image below. Note that this chart type is based upon the XYDiagram, so it can be rotated to show areas either vertically or horizontally.

Chart Type Characteristics

The table below lists the main characteristics of this chart type.

FeatureValue
Series View typeRangeAreaSeriesView
Diagram type2D-XYDiagram
Number of arguments per series point1
Number of values per series point2

Note

For information on which chart types can be combined with the Range Area Chart , refer to the Series Views Compatibility document.

Example

The following example demonstrates how to create a ChartControl with a series of the RangeAreaSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, first create a Windows Forms Application in Visual Studio, and include all necessary assemblies to the References list of your project.

Then, add the following code to the Form.Load event handler.

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace RangeAreaChart {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, System.EventArgs e) {
            // Create a new chart.
            ChartControl rangeAreaChart = new ChartControl();

            // Create a range area series.
            Series series1 = new Series("Series 1", ViewType.RangeArea);

            // Add points to them.
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 1), 2.08, 4.28));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 2), 2.42, 4.03));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 3), 2.78, 3.98));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 4), 2.57, 3.94));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 5), 2.69, 4.18));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 6), 2.69, 5.02));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 7), 2.36, 5.60));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 8), 1.97, 5.37));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 9), 2.76, 4.94));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 10), 3.54, 3.66));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 11), 4.31, 1.07));
            series1.Points.Add(new SeriesPoint(new DateTime(2008, 1, 12), 4.08, 0.09));

            // Add a series to the chart.
            rangeAreaChart.Series.Add(series1);

            // Access the view-type-specific options of the series.
            ((RangeAreaSeriesView)series1.View).Transparency = 80;

            // Access the type-specific options of the diagram.
            ((XYDiagram)rangeAreaChart.Diagram).AxisX.GridLines.Visible = true;
            ((XYDiagram)rangeAreaChart.Diagram).AxisY.WholeRange.MinValue = -0.5;
            ((XYDiagram)rangeAreaChart.Diagram).AxisY.WholeRange.MaxValue = 6;

            // Hide the legend (if necessary).
            rangeAreaChart.Legend.Visible = false;

            // Add a title to the chart (if necessary).
            rangeAreaChart.Titles.Add(new ChartTitle());
            rangeAreaChart.Titles[0].Text = "A Range Area Chart";

            // Add the chart to the form.
            rangeAreaChart.Dock = DockStyle.Fill;
            this.Controls.Add(rangeAreaChart);
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts

Namespace RangeAreaChart
    Partial Public Class Form1
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' Create a new chart.
            Dim rangeAreaChart As New ChartControl()

            ' Create a range area series.
            Dim series1 As New Series("Series 1", ViewType.RangeArea)

            ' Add points to them.
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 1), 2.08, 4.28))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 2), 2.42, 4.03))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 3), 2.78, 3.98))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 4), 2.57, 3.94))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 5), 2.69, 4.18))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 6), 2.69, 5.02))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 7), 2.36, 5.60))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 8), 1.97, 5.37))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 9), 2.76, 4.94))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 10), 3.54, 3.66))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 11), 4.31, 1.07))
            series1.Points.Add(New SeriesPoint(New DateTime(2008, 1, 12), 4.08, 0.09))

            ' Add a series to the chart.
            rangeAreaChart.Series.Add(series1)

            ' Access the view-type-specific options of the series.
            CType(series1.View, RangeAreaSeriesView).Transparency = 80

            ' Access the type-specific options of the diagram.
            CType(rangeAreaChart.Diagram, XYDiagram).AxisX.GridLines.Visible = True
            CType(rangeAreaChart.Diagram, XYDiagram).AxisY.WholeRange.MinValue = -0.5
            CType(rangeAreaChart.Diagram, XYDiagram).AxisY.WholeRange.MaxValue = 6

            ' Hide the legend (if necessary).
            rangeAreaChart.Legend.Visible = False

            ' Add a title to the chart (if necessary).
            rangeAreaChart.Titles.Add(New ChartTitle())
            rangeAreaChart.Titles(0).Text = "A Range Area Chart"

            ' Add the chart to the form.
            rangeAreaChart.Dock = DockStyle.Fill
            Me.Controls.Add(rangeAreaChart)
        End Sub
    End Class
End Namespace