Back to Devexpress

Full-Stacked Line Chart

windowsforms-9978-controls-and-libraries-chart-control-series-views-2d-series-views-point-and-line-series-views-full-stacked-line-chart.md

latest7.6 KB
Original Source

Full-Stacked Line Chart

  • Jul 08, 2019
  • 4 minutes to read

Short Description

The Full-Stacked Line Chart (100%-Stacked Line Chart) is represented by the FullStackedLineSeriesView object, which belongs to Point and Line Series Views. This chart is useful when it is necessary to compare how much each series adds to the total aggregate value for specific arguments.

A Full-Stacked Line chart is shown in the image below. Note that this chart type is based upon XYDiagram, and so it can be rotated to show lines either vertically or horizontally.

Note

A Full-Stacked Line chart can display series containing data points with positive or negative values. However, a series with positive values is stacked only with other series containing positive values; and a series with negative values is stacked with other series containing negative values.

Note that if a series contains data points with both positive and negative values, it is treated as a series with positive values, while all its negative values are treated as zeros.

Chart Type Characteristics

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

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

Note

For information on which chart types can be combined with the Full-Stacked Line Chart , refer to the Series Views Compatibility document.

Example

The following example demonstrates how to create a ChartControl with a series of the FullStackedLineSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, create a Windows Forms Application in Visual Studio, and add all required 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 FullStackedLineChart {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {

            // Create a new chart.
            ChartControl fullStackedLineChart = new ChartControl();

            // Create two full-stacked line series.
            Series series1 = new Series("Series 1", ViewType.FullStackedLine);
            Series series2 = new Series("Series 2", ViewType.FullStackedLine);

            // Add points to them.
            series1.Points.Add(new SeriesPoint(new DateTime(1997, 1, 11), 10));
            series1.Points.Add(new SeriesPoint(new DateTime(1999, 1, 11), 962));
            series1.Points.Add(new SeriesPoint(new DateTime(2001, 1, 11), 18832));
            series1.Points.Add(new SeriesPoint(new DateTime(2003, 1, 11), 264332));
            series1.Points.Add(new SeriesPoint(new DateTime(2005, 1, 11), 1112753));
            series1.Points.Add(new SeriesPoint(new DateTime(2007, 1, 11), 4169758));

            series2.Points.Add(new SeriesPoint(new DateTime(1997, 1, 11), 391));
            series2.Points.Add(new SeriesPoint(new DateTime(1999, 1, 11), 4082));
            series2.Points.Add(new SeriesPoint(new DateTime(2001, 1, 11), 21932));
            series2.Points.Add(new SeriesPoint(new DateTime(2003, 1, 11), 64195));
            series2.Points.Add(new SeriesPoint(new DateTime(2005, 1, 11), 78473));
            series2.Points.Add(new SeriesPoint(new DateTime(2007, 1, 11), 101830));

            // Add both series to the chart.
            fullStackedLineChart.Series.AddRange(new Series[] { series1, series2 });

            // Access the type-specific options of the diagram.
            ((XYDiagram)fullStackedLineChart.Diagram).EnableAxisXZooming = true;
            ((XYDiagram)fullStackedLineChart.Diagram).AxisY.Label.TextPattern = "{VP:P0}";

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

            // Add a title to the chart (if necessary).
            fullStackedLineChart.Titles.Add(new ChartTitle());
            fullStackedLineChart.Titles[0].Text = "Full Stacked Line Chart";

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

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

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

            ' Create a new chart.
            Dim fullStackedLineChart As New ChartControl()

            ' Create two full-stacked line series.
            Dim series1 As New Series("Series 1", ViewType.FullStackedLine)
            Dim series2 As New Series("Series 2", ViewType.FullStackedLine)

            ' Add points to them.
            series1.Points.Add(New SeriesPoint(New DateTime(1997, 1, 11), 10))
            series1.Points.Add(New SeriesPoint(New DateTime(1999, 1, 11), 962))
            series1.Points.Add(New SeriesPoint(New DateTime(2001, 1, 11), 18832))
            series1.Points.Add(New SeriesPoint(New DateTime(2003, 1, 11), 264332))
            series1.Points.Add(New SeriesPoint(New DateTime(2005, 1, 11), 1112753))
            series1.Points.Add(New SeriesPoint(New DateTime(2007, 1, 11), 4169758))

            series2.Points.Add(New SeriesPoint(New DateTime(1997, 1, 11), 391))
            series2.Points.Add(New SeriesPoint(New DateTime(1999, 1, 11), 4082))
            series2.Points.Add(New SeriesPoint(New DateTime(2001, 1, 11), 21932))
            series2.Points.Add(New SeriesPoint(New DateTime(2003, 1, 11), 64195))
            series2.Points.Add(New SeriesPoint(New DateTime(2005, 1, 11), 78473))
            series2.Points.Add(New SeriesPoint(New DateTime(2007, 1, 11), 101830))

            ' Add both series to the chart.
            fullStackedLineChart.Series.AddRange(New Series() { series1, series2 })

            ' Access the type-specific options of the diagram.
            CType(fullStackedLineChart.Diagram, XYDiagram).EnableAxisXZooming = True
            CType(fullStackedLineChart.Diagram, XYDiagram).AxisY.Label.TextPattern = "{VP:P0}"

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

            ' Add a title to the chart (if necessary).
            fullStackedLineChart.Titles.Add(New ChartTitle())
            fullStackedLineChart.Titles(0).Text = "Full Stacked Line Chart"

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