Back to Devexpress

SummaryDataAdapter Class

corelibraries-devexpress-dot-xtracharts-42c875aa.md

latest14.2 KB
Original Source

SummaryDataAdapter Class

An adapter that creates series points based on data source item summaries.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public class SummaryDataAdapter :
    CachedPointDataAdapter,
    ISummaryAdapter,
    ISummaryOptionsOwner
vb
Public Class SummaryDataAdapter
    Inherits CachedPointDataAdapter
    Implements ISummaryAdapter,
               ISummaryOptionsOwner

Remarks

The SummaryDataAdapter allows you to summarize values of points with the same arguments.

Depending on the argument axis scale type, you should use one of the following properties to define scale-specific options:

The SummaryOptionsBase.SummaryFunction property allows you to specify the function used to summarize points. The following functions are available:

  • MIN([Data_Member_Name])
  • MAX([Data_Member_Name])
  • AVERAGE([Data_Member_Name])
  • SUM([Data_Member_Name])
  • COUNT()

Some functions require you to specify the data member name (the Data_Member_Name parameter) that supplies values to summarize.

Use the ChartControl.RegisterSummaryFunction method to create a new function.

Example

The following example shows how to create a series and aggregate points with equal arguments.

A summary function is not applied.A summary function (SUM) is applied.
csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace SummaryChart {
        private void OnLoad(object sender, EventArgs e) {
            // Create a series.
            Series series = new Series("Series", ViewType.Point);

            // Create a summary data adapter.
            SummaryDataAdapter dataAdapter = new SummaryDataAdapter();

            // Specify the data source.
            dataAdapter.DataSource = SaleInfo.GetSaleInfos();

            // Create a data member that defines arguments.
            dataAdapter.DataMembers.Add(new DataMember {
                DataMemberType = ChartDataMemberType.Argument,
                ColumnName = "Category",
                ScaleType = ScaleType.Qualitative
            });
            // Create a data member that defines values.
            dataAdapter.DataMembers.Add(new DataMember {
                DataMemberType = ChartDataMemberType.Value,
                ColumnName = "Value",
                ScaleType = ScaleType.Numerical
            });

            // Specify a summary function.
            dataAdapter.QualitativeSummaryOptions.SummaryFunction = "SUM([Value])";

            // Assign the data adapter to the series.
            series.DataAdapter = dataAdapter;

            // Add the series to the chart.
            chart.Series.Add(series);

        }

        public class SaleInfo {
            public string Category { get; set; }
            public string Region { get; set; }
            public double Value { get; set; }

            public static List<SaleInfo> GetSaleInfos() {
                return new List<SaleInfo> {
                    new SaleInfo { Category= "Video players", Region = "Asia", Value = 853D},
                    new SaleInfo { Category= "Video players", Region = "Australia", Value = 321D},
                    new SaleInfo { Category= "Video players", Region = "Europe", Value = 655D},
                    new SaleInfo { Category= "Video players", Region = "North America", Value = 1325D},
                    new SaleInfo { Category= "Video players", Region = "South America", Value = 653D},
                    new SaleInfo { Category= "Automation", Region = "Asia", Value = 172D},
                    new SaleInfo { Category= "Automation", Region = "Australia", Value = 255D},
                    new SaleInfo { Category= "Automation", Region = "Europe", Value = 981D},
                    new SaleInfo { Category= "Automation", Region = "North America", Value = 963D},
                    new SaleInfo { Category= "Automation", Region = "South America", Value = 123D},
                    new SaleInfo { Category= "Monitors", Region = "Asia", Value = 1011D},
                    new SaleInfo { Category= "Monitors", Region = "Australia", Value = 359D},
                    new SaleInfo { Category= "Monitors", Region = "Europe", Value = 721D},
                    new SaleInfo { Category= "Monitors", Region = "North America", Value = 565D},
                    new SaleInfo { Category= "Monitors", Region = "South America", Value = 532D},
                    new SaleInfo { Category= "Projectors", Region = "Asia", Value = 998D},
                    new SaleInfo { Category= "Projectors", Region = "Australia", Value = 222D},
                    new SaleInfo { Category= "Projectors", Region = "Europe", Value = 865D},
                    new SaleInfo { Category= "Projectors", Region = "North America", Value = 787D},
                    new SaleInfo { Category= "Projectors", Region = "South America", Value = 332D},
                    new SaleInfo { Category= "Televisions", Region = "Asia", Value = 1356D},
                    new SaleInfo { Category= "Televisions", Region = "Australia", Value = 232D},
                    new SaleInfo { Category= "Televisions", Region = "Europe", Value = 1323D},
                    new SaleInfo { Category= "Televisions", Region = "North America", Value = 1125D},
                    new SaleInfo { Category= "Televisions", Region = "South America", Value = 865D}
                };
            }
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts

Namespace SummaryChart
    Private Sub OnLoad(ByVal sender As Object, ByVal e As EventArgs)
        ' Create a series.
        Dim series As Series = New Series("Series", ViewType.Point)
        ' Create a summary data adapter.
        Dim dataAdapter As SummaryDataAdapter = New SummaryDataAdapter()
        ' Specify the data source.
        dataAdapter.DataSource = SaleInfo.GetSaleInfos()
        ' Create a data member that defines arguments.
        dataAdapter.DataMembers.Add(New DataMember With {
            .DataMemberType = ChartDataMemberType.Argument,
            .ColumnName = "Category",
            .ScaleType = ScaleType.Qualitative
        })
        ' Create a data member that defines values.
        dataAdapter.DataMembers.Add(New DataMember With {
            .DataMemberType = ChartDataMemberType.Value,
            .ColumnName = "Value",
            .ScaleType = ScaleType.Numerical
        })
        ' Specify a summary function.
        dataAdapter.QualitativeSummaryOptions.SummaryFunction = "SUM([Value])"
        ' Assign the data adapter to the series.
        series.DataAdapter = dataAdapter
        ' Add the series to the chart.
        chart.Series.Add(series)
    End Sub

    Public Class SaleInfo
        Public Property Category As String
        Public Property Region As String
        Public Property Value As Double

        Public Shared Function GetSaleInfos() As List(Of SaleInfo)
            Return New List(Of SaleInfo) From {
                New SaleInfo With {
                    .Category = "Video players",
                    .Region = "Asia",
                    .Value = 853R
                },
                New SaleInfo With {
                    .Category = "Video players",
                    .Region = "Australia",
                    .Value = 321R
                },
                New SaleInfo With {
                    .Category = "Video players",
                    .Region = "Europe",
                    .Value = 655R
                },
                New SaleInfo With {
                    .Category = "Video players",
                    .Region = "North America",
                    .Value = 1325R
                },
                New SaleInfo With {
                    .Category = "Video players",
                    .Region = "South America",
                    .Value = 653R
                },
                New SaleInfo With {
                    .Category = "Automation",
                    .Region = "Asia",
                    .Value = 172R
                },
                New SaleInfo With {
                    .Category = "Automation",
                    .Region = "Australia",
                    .Value = 255R
                },
                New SaleInfo With {
                    .Category = "Automation",
                    .Region = "Europe",
                    .Value = 981R
                },
                New SaleInfo With {
                    .Category = "Automation",
                    .Region = "North America",
                    .Value = 963R
                },
                New SaleInfo With {
                    .Category = "Automation",
                    .Region = "South America",
                    .Value = 123R
                },
                New SaleInfo With {
                    .Category = "Monitors",
                    .Region = "Asia",
                    .Value = 1011R
                },
                New SaleInfo With {
                    .Category = "Monitors",
                    .Region = "Australia",
                    .Value = 359R
                },
                New SaleInfo With {
                    .Category = "Monitors",
                    .Region = "Europe",
                    .Value = 721R
                },
                New SaleInfo With {
                    .Category = "Monitors",
                    .Region = "North America",
                    .Value = 565R
                },
                New SaleInfo With {
                    .Category = "Monitors",
                    .Region = "South America",
                    .Value = 532R
                },
                New SaleInfo With {
                    .Category = "Projectors",
                    .Region = "Asia",
                    .Value = 998R
                },
                New SaleInfo With {
                    .Category = "Projectors",
                    .Region = "Australia",
                    .Value = 222R
                },
                New SaleInfo With {
                    .Category = "Projectors",
                    .Region = "Europe",
                    .Value = 865R
                },
                New SaleInfo With {
                    .Category = "Projectors",
                    .Region = "North America",
                    .Value = 787R
                },
                New SaleInfo With {
                    .Category = "Projectors",
                    .Region = "South America",
                    .Value = 332R
                },
                New SaleInfo With {
                    .Category = "Televisions",
                    .Region = "Asia",
                    .Value = 1356R
                },
                New SaleInfo With {
                    .Category = "Televisions",
                    .Region = "Australia",
                    .Value = 232R
                },
                New SaleInfo With {
                    .Category = "Televisions",
                    .Region = "Europe",
                    .Value = 1323R
                },
                New SaleInfo With {
                    .Category = "Televisions",
                    .Region = "North America",
                    .Value = 1125R
                },
                New SaleInfo With {
                    .Category = "Televisions",
                    .Region = "South America",
                    .Value = 865R
                }
            }
        End Function
    End Class
End Namespace

Implements

IXtraSupportDeserializeCollectionItem

ISeriesAdapter

IChartDataAdapter

Inheritance

Object ChartElement BaseDataAdapter DataSourceAdapterBase DataSourceAdapter CachedPointDataAdapter SummaryDataAdapter

See Also

SummaryDataAdapter Members

Best Practices: Display Large Data

DevExpress.XtraCharts Namespace