corelibraries-devexpress-dot-xtracharts-dot-summarydataadapter-08001140.md
Returns options that configure how the series calculates summary values of its data source with TimeSpan arguments.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[PersistenceMode(PersistenceMode.InnerProperty)]
[XtraChartsLocalizableCategory(XtraChartsCategory.Data)]
public TimeSpanSummaryOptions TimeSpanSummaryOptions { get; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Data)>
<PersistenceMode(PersistenceMode.InnerProperty)>
Public ReadOnly Property TimeSpanSummaryOptions As TimeSpanSummaryOptions
| Type | Description |
|---|---|
| TimeSpanSummaryOptions |
Stores summarization settings for a chart with TimeSpan arguments.
|
The TimeSpanSummaryOptions include the SummaryFunction property, which defines a function used to summarize series values.
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. |
|---|---|
Create a SummaryDataAdapter object.
Define the adapter’s DataSource property.
Populate the adapter DataMembers collection. You should specify data members that contain arguments and values.
Specify the SummaryOptionsBase.SummaryFunction property to select a function used to summarize values.
Use the Series.DataAdapter property to assign the adapter to the series.
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.TimeSpan
});
// 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.TimeSpanSummaryOptions.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 DataPoint {
public TimeSpan Argument { get; set; }
public double Value { get; set; }
public static List<DataPoint> GetDataPoints() {
return new List<DataPoint> {
new DataPoint { Argument= new TimeSpan(1,0,0), Value = 853D},
new DataPoint { Argument= new TimeSpan(1,0,0), Value = 321D},
new DataPoint { Argument= new TimeSpan(1,0,0), Value = 655D},
new DataPoint { Argument= new TimeSpan(1,0,0), Value = 1325D},
new DataPoint { Argument= new TimeSpan(2,0,0), Value = 653D},
new DataPoint { Argument= new TimeSpan(2,0,0), Value = 172D},
new DataPoint { Argument= new TimeSpan(2,0,0), Value = 255D},
new DataPoint { Argument= new TimeSpan(3,0,0), Value = 981D},
new DataPoint { Argument= new TimeSpan(3,0,0), Value = 963D},
new DataPoint { Argument= new TimeSpan(4,0,0), Value = 123D},
new DataPoint { Argument= new TimeSpan(4,0,0), Value = 1011D},
new DataPoint { Argument= new TimeSpan(4,0,0), Value = 359D},
new DataPoint { Argument= new TimeSpan(4,0,0), Value = 721D},
new DataPoint { Argument= new TimeSpan(4,0,0), Value = 565D}
};
}
}
}
}
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.TimeSpan
})
' 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.TimeSpanSummaryOptions.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 DataPoint
Public Property Argument As TimeSpan
Public Property Value As Double
Public Shared Function GetDataPoints() As List(Of DataPoint)
Return New List(Of DataPoint) From {
New DataPoint With {
.Argument = New TimeSpan(1, 0, 0),
.Value = 853R
},
New DataPoint With {
.Argument = New TimeSpan(1, 0, 0),
.Value = 321R
},
New DataPoint With {
.Argument = New TimeSpan(1, 0, 0),
.Value = 655R
},
New DataPoint With {
.Argument = New TimeSpan(1, 0, 0),
.Value = 1325R
},
New DataPoint With {
.Argument = New TimeSpan(2, 0, 0),
.Value = 653R
},
New DataPoint With {
.Argument = New TimeSpan(2, 0, 0),
.Value = 172R
},
New DataPoint With {
.Argument = New TimeSpan(2, 0, 0),
.Value = 255R
},
New DataPoint With {
.Argument = New TimeSpan(3, 0, 0),
.Value = 981R
},
New DataPoint With {
.Argument = New TimeSpan(3, 0, 0),
.Value = 963R
},
New DataPoint With {
.Argument = New TimeSpan(4, 0, 0),
.Value = 123R
},
New DataPoint With {
.Argument = New TimeSpan(4, 0, 0),
.Value = 1011R
},
New DataPoint With {
.Argument = New TimeSpan(4, 0, 0),
.Value = 359R
},
New DataPoint With {
.Argument = New TimeSpan(4, 0, 0),
.Value = 721R
},
New DataPoint With {
.Argument = New TimeSpan(4, 0, 0),
.Value = 565R
}
}
End Function
End Class
End Class
End Namespace
See Also