corelibraries-devexpress-dot-xtracharts-9d70133d.md
A base class for the SeriesTemplate and Series classes.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
public class SeriesBase :
ChartElement,
ISeriesBase,
ISeriesDataAdapter,
ISeriesPointFactory,
IHitTest,
IXtraSupportCreateContentPropertyValue,
IXtraSupportDeserializeCollectionItem,
ITopNOptions,
IPointsFilterOptions,
ICheckableLegendItem,
ILegendItem,
IFilteredComponent,
IFilteredComponentBase,
IFilteringUIClient,
IFilterCriteriaBindingAware,
IFilterCriteriaProvider,
ISeriesProvider,
ISummaryOptionsOwner
Public Class SeriesBase
Inherits ChartElement
Implements ISeriesBase,
ISeriesDataAdapter,
ISeriesPointFactory,
IHitTest,
IXtraSupportCreateContentPropertyValue,
IXtraSupportDeserializeCollectionItem,
ITopNOptions,
IPointsFilterOptions,
ICheckableLegendItem,
ILegendItem,
IFilteredComponent,
IFilteredComponentBase,
IFilteringUIClient,
IFilterCriteriaBindingAware,
IFilterCriteriaProvider,
ISeriesProvider,
ISummaryOptionsOwner
The following members return SeriesBase objects:
The SeriesBase class contains the core functionality of the series objects. Use the ChartControl.SeriesTemplate property to access these settings if you bind a Chart Control to a data source. When you add series manually, Series objects contain inherited API members from the SeriesBase class.
The table below lists the main API members:
|
Member
|
Description
| | --- | --- | |
|
Contains the series view settings.
| |
|
Changes the series view type.
| |
|
Gets or sets the data field name that contains series point arguments.
| |
|
Gets a collection of data field names that contain series point values.
| |
SeriesBase.ArgumentScaleType, SeriesBase.ValueScaleType
|
Specify the scale type for axes.
| |
SeriesBase.FilterCriteria, SeriesBase.FilterString
|
Filter the series data.
| |
|
Defines series label settings.
| |
SeriesBase.SeriesPointsSorting, SeriesBase.SeriesPointsSortingKey
|
Specify sort settings.
| |
|
Specifies whether the chart shows the series in a legend.
| |
|
Defines whether the series is visible.
|
This example simultaneously configures settings for template series and a series added to the chart manually.
Follow the steps below to implement this scenario:
Create a Windows Forms Application in Visual Studio, and add all required assemblies to the References list of your project.
Create a chart in the Form1_Load event handler.
Populate the chart with autogenerated series:
Call the custom ConfigureSeries method with the ChartControl.SeriesTemplate object passed as a parameter to specify the following settings for all template series: ArgumentDataMember, ValueDataMembers, ArgumentScaleType, ValueScaleType, LabelsVisibility, and Label.TextPattern.
Add a single series:
Call the custom ConfigureSeries method with the series passed as a parameter to specify series settings.
Use the ChartControl.Dock property to specify the chart position. Call the Controls.Add method to add the chart to the form.
using DevExpress.XtraCharts;
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.Utils;
namespace series_base_example {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
ChartControl chart = new ChartControl();
// Hide the legend.
chart.Legend.Visibility = DefaultBoolean.False;
// Define the series template for multiple series.
chart.DataSource = GetSeriesTemplateData();
chart.SeriesDataMember = "Region";
chart.SeriesTemplate.View = new LineSeriesView();
ConfigureSeries(chart.SeriesTemplate);
// Add a single series.
Series series = new Series("Australia", ViewType.Area);
series.DataSource = GetSeriesData();
chart.Series.Add(series);
ConfigureSeries(series);
chart.Dock = DockStyle.Fill;
this.Controls.Add(chart);
}
private void ConfigureSeries(SeriesBase series) {
series.ArgumentDataMember = "Year";
series.ValueDataMembers.AddRange(new string[] { "Sales" });
series.ArgumentScaleType= ScaleType.Qualitative;
series.ValueScaleType= ScaleType.Numerical;
series.LabelsVisibility = DefaultBoolean.True;
series.Label.TextPattern = "{A}: {V:F2}";
}
internal static DataTable GetSeriesTemplateData() {
DataTable table = new DataTable();
table.Columns.AddRange(new DataColumn[] { new DataColumn("Region", typeof(string)),
new DataColumn("Year", typeof(int)),
new DataColumn("Sales", typeof(decimal)) });
table.Rows.Add("Asia", 2016, 3.9341D);
table.Rows.Add("Asia", 2017, 4.2372D);
table.Rows.Add("Asia", 2018, 4.7685D);
table.Rows.Add("Asia", 2019, 5.2890D);
table.Rows.Add("Europe", 2016, 2.7891D);
table.Rows.Add("Europe", 2017, 3.0884D);
table.Rows.Add("Europe", 2018, 3.3579D);
table.Rows.Add("Europe", 2019, 3.7257D);
table.Rows.Add("North America", 2016, 3.2566D);
table.Rows.Add("North America", 2017, 3.4855D);
table.Rows.Add("North America", 2018, 3.7477D);
table.Rows.Add("North America", 2019, 4.1825D);
return table;
}
internal static DataTable GetSeriesData() {
DataTable table = new DataTable();
table.Columns.AddRange(new DataColumn[] { new DataColumn("Region", typeof(string)),
new DataColumn("Year", typeof(int)),
new DataColumn("Sales", typeof(decimal)) });
table.Rows.Add("Australia", 2016, 1.5632D);
table.Rows.Add("Australia", 2017, 1.7871D);
table.Rows.Add("Australia", 2018, 1.9576D);
table.Rows.Add("Australia", 2019, 2.2727D);
return table;
}
}
}
Imports DevExpress.XtraCharts
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports DevExpress.Utils
Namespace series_base_example
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim chart As ChartControl = New ChartControl()
' Hide the legend.
chart.Legend.Visibility = DefaultBoolean.[False]
' Define the series template for multiple series.
chart.DataSource = GetSeriesTemplateData()
chart.SeriesDataMember = "Region"
chart.SeriesTemplate.View = New LineSeriesView()
ConfigureSeries(chart.SeriesTemplate)
' Add a single series.
Dim series As Series = New Series("Australia", ViewType.Area)
series.DataSource = GetSeriesData()
chart.Series.Add(series)
ConfigureSeries(series)
chart.Dock = DockStyle.Fill
Me.Controls.Add(chart)
End Sub
Private Sub ConfigureSeries(ByVal series As SeriesBase)
series.ArgumentDataMember = "Year"
series.ValueDataMembers.AddRange(New String() {"Sales"})
series.ArgumentScaleType = ScaleType.Qualitative
series.ValueScaleType = ScaleType.Numerical
series.LabelsVisibility = DefaultBoolean.True
series.Label.TextPattern = "{A}: {V:F2}"
End Sub
Friend Shared Function GetSeriesTemplateData() As DataTable
Dim table As DataTable = New DataTable()
table.Columns.AddRange(New DataColumn() {New DataColumn("Region", GetType(String)), New DataColumn("Year", GetType(Integer)), New DataColumn("Sales", GetType(Decimal))})
table.Rows.Add("Asia", 2016, 3.9341R)
table.Rows.Add("Asia", 2017, 4.2372R)
table.Rows.Add("Asia", 2018, 4.7685R)
table.Rows.Add("Asia", 2019, 5.2890R)
table.Rows.Add("Europe", 2016, 2.7891R)
table.Rows.Add("Europe", 2017, 3.0884R)
table.Rows.Add("Europe", 2018, 3.3579R)
table.Rows.Add("Europe", 2019, 3.7257R)
table.Rows.Add("North America", 2016, 3.2566R)
table.Rows.Add("North America", 2017, 3.4855R)
table.Rows.Add("North America", 2018, 3.7477R)
table.Rows.Add("North America", 2019, 4.1825R)
Return table
End Function
Friend Shared Function GetSeriesData() As DataTable
Dim table As DataTable = New DataTable()
table.Columns.AddRange(New DataColumn() {New DataColumn("Region", GetType(String)), New DataColumn("Year", GetType(Integer)), New DataColumn("Sales", GetType(Decimal))})
table.Rows.Add("Australia", 2016, 1.5632R)
table.Rows.Add("Australia", 2017, 1.7871R)
table.Rows.Add("Australia", 2018, 1.9576R)
table.Rows.Add("Australia", 2019, 2.2727R)
Return table
End Function
End Class
End Namespace
IXtraSupportDeserializeCollectionItem
Object ChartElement SeriesBase Series
See Also