Back to Devexpress

SummaryDataAdapter.DateTimeSummaryOptions Property

corelibraries-devexpress-dot-xtracharts-dot-summarydataadapter-211628b9.md

latest10.0 KB
Original Source

SummaryDataAdapter.DateTimeSummaryOptions Property

Returns options that configure how the series calculates summary values of its data source with DateTime arguments.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[PersistenceMode(PersistenceMode.InnerProperty)]
[XtraChartsLocalizableCategory(XtraChartsCategory.Data)]
public DateTimeSummaryOptions DateTimeSummaryOptions { get; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Data)>
<PersistenceMode(PersistenceMode.InnerProperty)>
Public ReadOnly Property DateTimeSummaryOptions As DateTimeSummaryOptions

Property Value

TypeDescription
DateTimeSummaryOptions

Stores summarization settings for a chart with DateTime arguments.

|

Remarks

The DateTimeSummaryOptions include the SummaryFunction property, which defines a function used to summarize series values.

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 DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace SummaryChart {
    public partial class Form1 : Form {

        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 = DataPoint.GetDataPoints();

            // Create a data member that defines arguments.
            dataAdapter.DataMembers.Add(new DataMember {
                DataMemberType = ChartDataMemberType.Argument,
                ColumnName = "Argument",
                ScaleType = ScaleType.DateTime
            });
            // 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.DateTimeSummaryOptions.SummaryFunction = "SUM([Value])";

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

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

            XYDiagram xYDiagram = chart.Diagram as XYDiagram;
            xYDiagram.AxisX.Label.TextPattern = "{A:MMMM}";
        }

        public class DataPoint {
            public DateTime Argument { get; set; }
            public double Value { get; set; }

            public static List<DataPoint> GetDataPoints() {
                return new List<DataPoint> {
                    new DataPoint { Argument= new DateTime(2020,1,1), Value = 853D},
                    new DataPoint { Argument= new DateTime(2020,1,1), Value = 321D},
                    new DataPoint { Argument= new DateTime(2020,1,1), Value = 655D},
                    new DataPoint { Argument= new DateTime(2020,2,1), Value = 1325D},
                    new DataPoint { Argument= new DateTime(2020,2,1), Value = 653D},
                    new DataPoint { Argument= new DateTime(2020,2,1), Value = 172D},
                    new DataPoint { Argument= new DateTime(2020,2,1), Value = 255D},
                    new DataPoint { Argument= new DateTime(2020,2,1), Value = 981D},
                    new DataPoint { Argument= new DateTime(2020,3,1), Value = 963D},
                    new DataPoint { Argument= new DateTime(2020,3,1), Value = 123D},
                    new DataPoint { Argument= new DateTime(2020,3,1), Value = 1011D},
                    new DataPoint { Argument= new DateTime(2020,3,1), Value = 359D},
                    new DataPoint { Argument= new DateTime(2020,4,1), Value = 721D},
                    new DataPoint { Argument= new DateTime(2020,4,1), Value = 565D}
                };
            }
        }
    }
}
vb
Imports DevExpress.XtraCharts
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms

Namespace SummaryChart
    Public Partial Class Form1
        Inherits Form

        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 = DataPoint.GetDataPoints()

            ' Create a data member that defines arguments.
            dataAdapter.DataMembers.Add(New DataMember With {
                .DataMemberType = ChartDataMemberType.Argument,
                .ColumnName = "Argument",
                .ScaleType = ScaleType.DateTime
            })
            ' 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.DateTimeSummaryOptions.SummaryFunction = "SUM([Value])"

            ' Assign the data adapter to the series.
            series.DataAdapter = dataAdapter

            ' Add the series to the chart.
            chart.Series.Add(series)
            Dim xYDiagram As XYDiagram = TryCast(chart.Diagram, XYDiagram)
            xYDiagram.AxisX.Label.TextPattern = "{A:MMMM}"
        End Sub

        Public Class DataPoint
            Public Property Argument As Date
            Public Property Value As Double

            Public Shared Function GetDataPoints() As List(Of DataPoint)
                Return New List(Of DataPoint) From {
                    New DataPoint With {
                        .Argument = New DateTime(2020, 1, 1),
                        .Value = 853R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 1, 1),
                        .Value = 321R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 1, 1),
                        .Value = 655R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 2, 1),
                        .Value = 1325R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 2, 1),
                        .Value = 653R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 2, 1),
                        .Value = 172R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 2, 1),
                        .Value = 255R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 2, 1),
                        .Value = 981R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 3, 1),
                        .Value = 963R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 3, 1),
                        .Value = 123R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 3, 1),
                        .Value = 1011R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 3, 1),
                        .Value = 359R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 4, 1),
                        .Value = 721R
                    },
                    New DataPoint With {
                        .Argument = New DateTime(2020, 4, 1),
                        .Value = 565R
                    }
                }
            End Function
        End Class
    End Class
End Namespace

See Also

SummaryDataAdapter Class

SummaryDataAdapter Members

DevExpress.XtraCharts Namespace