corelibraries-devexpress-dot-xtracharts-cf6d8611.md
An adapter that creates series based on a template and summarizes series points.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
public class SeriesTemplateSummaryAdapter :
SeriesTemplateAdapter,
ISupportIndexAdapter<ISeries>,
ISummaryAdapter,
ISummaryOptionsOwner
Public Class SeriesTemplateSummaryAdapter
Inherits SeriesTemplateAdapter
Implements ISupportIndexAdapter(Of ISeries),
ISummaryAdapter,
ISummaryOptionsOwner
The SeriesTemplateSummaryAdapter allows you to create multiple series based on a template and summarize values of points with the same arguments.
Depending on the argument axis scale type, 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:
Some functions require you to specify the data member name (the Data_Member_Name parameter) that supplies values to summarize.
To create a new function, use the ChartControl.RegisterSummaryFunction method.
The following example shows how to create multiple series based on a template and aggregate their points with equal arguments:
Define the chart control’s DataSource property.
Create a SeriesTemplateSummaryAdapter object.
Populate the adapter’s DataMembers collection. You should specify data members that contain point arguments, point values, and values that identify series.
Specify the SummaryOptionsBase.SummaryFunction property to select a function used to summarize values.
Use the SeriesTemplate.DataAdapter property to assign the adapter to the chart.
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) {
// Specify the chart data source.
chart.DataSource = DataPoint.GetDataPoints();
//Create a summary data adapter.
SeriesTemplateSummaryAdapter dataAdapter = new SeriesTemplateSummaryAdapter();
// Create a data member that defines arguments.
dataAdapter.DataMembers.Add(new DataMember {
DataMemberType = ChartDataMemberType.Argument,
ColumnName = "Argument",
ScaleType = ScaleType.Numerical
});
// Create a data member that defines values.
dataAdapter.DataMembers.Add(new DataMember {
DataMemberType = ChartDataMemberType.Value,
ColumnName = "Value",
ScaleType = ScaleType.Numerical
});
// Create a data member that identifies data series.
dataAdapter.DataMembers.Add(new DataMember {
DataMemberType = ChartDataMemberType.Series,
ColumnName = "Name",
ScaleType = ScaleType.Qualitative
});
// Specify a summary function.
dataAdapter.NumericSummaryOptions.SummaryFunction = "AVERAGE([Value])";
// Assign the data adapter to the chart.
chart.SeriesTemplate.DataAdapter = dataAdapter;
}
public class DataPoint {
public double Argument { get; set; }
public double Value { get; set; }
public string Name { get; set; }
public static List<DataPoint> GetDataPoints() {
return new List<DataPoint> {
new DataPoint { Argument= 1, Value = 853D, Name = "Series 2"},
new DataPoint { Argument= 1, Value = 321D, Name = "Series 2"},
new DataPoint { Argument= 1, Value = 655D, Name = "Series 1"},
new DataPoint { Argument= 1, Value = 1325D, Name = "Series 1"},
new DataPoint { Argument= 2, Value = 653D, Name = "Series 2"},
new DataPoint { Argument= 2, Value = 172D, Name = "Series 2"},
new DataPoint { Argument= 2, Value = 255D, Name = "Series 1"},
new DataPoint { Argument= 3, Value = 981D, Name = "Series 1"},
new DataPoint { Argument= 3, Value = 913D, Name = "Series 2"},
new DataPoint { Argument= 4, Value = 123D, Name = "Series 1"},
new DataPoint { Argument= 4, Value = 1011D, Name = "Series 1"},
new DataPoint { Argument= 4, Value = 359D, Name = "Series 2"},
new DataPoint { Argument= 4, Value = 721D, Name = "Series 2"},
new DataPoint { Argument= 4, Value = 565D, Name = "Series 1"}
};
}
}
}
}
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)
' Specify the chart data source.
chart.DataSource = DataPoint.GetDataPoints()
'Create a summary data adapter.
Dim dataAdapter As SeriesTemplateSummaryAdapter = New SeriesTemplateSummaryAdapter()
' Create a data member that defines arguments.
dataAdapter.DataMembers.Add(New DataMember With {
.DataMemberType = ChartDataMemberType.Argument,
.ColumnName = "Argument",
.ScaleType = ScaleType.Numerical
})
' Create a data member that defines values.
dataAdapter.DataMembers.Add(New DataMember With {
.DataMemberType = ChartDataMemberType.Value,
.ColumnName = "Value",
.ScaleType = ScaleType.Numerical
})
' Create a data member that identifies data series.
dataAdapter.DataMembers.Add(New DataMember With {
.DataMemberType = ChartDataMemberType.Series,
.ColumnName = "Name",
.ScaleType = ScaleType.Qualitative
})
' Specify a summary function.
dataAdapter.NumericSummaryOptions.SummaryFunction = "AVERAGE([Value])"
' Assign the data adapter to the chart.
chart.SeriesTemplate.DataAdapter = dataAdapter
End Sub
Public Class DataPoint
Public Property Argument As Double
Public Property Value As Double
Public Property Name As String
Public Shared Function GetDataPoints() As List(Of DataPoint)
Return New List(Of DataPoint) From {
New DataPoint With {
.Argument = 1,
.Value = 853R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 1,
.Value = 321R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 1,
.Value = 655R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 1,
.Value = 1325R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 2,
.Value = 653R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 2,
.Value = 172R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 2,
.Value = 255R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 3,
.Value = 981R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 3,
.Value = 913R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 4,
.Value = 123R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 4,
.Value = 1011R,
.Name = "Series 1"
},
New DataPoint With {
.Argument = 4,
.Value = 359R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 4,
.Value = 721R,
.Name = "Series 2"
},
New DataPoint With {
.Argument = 4,
.Value = 565R,
.Name = "Series 1"
}
}
End Function
End Class
End Class
End Namespace
IXtraSupportDeserializeCollectionItem
Object ChartElement BaseDataAdapter DataSourceAdapterBase SeriesTemplateAdapter SeriesTemplateSummaryAdapter
See Also
SeriesTemplateSummaryAdapter Members