All docs
V21.2
21.2
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ISeriesAdapter Interface

Interface that should be implemented by any class that can be used as a series data adapter.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v21.2.dll

Declaration

public interface ISeriesAdapter :
    IChartDataAdapter,
    ICloneable

The following members accept/return ISeriesAdapter objects:

Example

How to: Implement a Custom Chart Data Adapter

This example shows how to create an adapter that loads numeric data to the chart:

using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CustomDataAdapter {
    public partial class Form1 : Form {
        const long DataItemCount = 100000;
        const int MaxValue = 100;
        const int MinValue = 80;
        Random rand = new Random();
        public Form1() {
            InitializeComponent();

            Series series = new Series("Series", ViewType.Line);
            chartControl1.Series.Add(series);

            List<DataItem> dataItems = new List<DataItem>();
            for (int i = 0; i < DataItemCount; i++) {
                dataItems.Add(new DataItem(i, rand.NextDouble() * (MaxValue - MinValue) + MaxValue));
            }

            series.DataAdapter = new CustomNumericDataAdapter(dataItems);

            ((XYDiagram)chartControl1.Diagram).AxisY.WholeRange.AlwaysShowZeroLevel = false;

        }
    }
    public class DataItem {
        public double Argument { get; }
        public double Value { get; }
        public DataItem(double argument, double value) {
            Argument = argument;
            Value = value;
        }
    }
    public class CustomNumericDataAdapter : ISeriesAdapter {
        readonly IList<DataItem> items;
        public bool DataSorted => true;
        public int ItemsCount => this.items.Count;
        public CustomNumericDataAdapter(IList<DataItem> items) {
            this.items = items;
        }
        event NotifyChartDataChangedEventHandler IChartDataAdapter.DataChanged {
            add { }
            remove { }
        }
        public object Clone() {
            return this;
        }
        public double GetNumericalValue(int index, ChartDataMemberType dataMember) {
            switch (dataMember) {
                case ChartDataMemberType.Argument: return items[index].Argument;
                case ChartDataMemberType.Value: return items[index].Value;
            }
            return double.NaN;
        }
        public object GetSourceObject(int index) {
            return this.items[index];
        }
        public ActualScaleType GetScaleType(ChartDataMemberType dataMember) {
            return ActualScaleType.Numerical;
        }
        public DateTime GetDateTimeValue(int index, ChartDataMemberType dataMember) {
            throw new NotImplementedException();
        }
        public string GetQualitativeValue(int index, ChartDataMemberType dataMember) {
            throw new NotImplementedException();
        }
        public TimeSpan GetTimeSpanValue(int index, ChartDataMemberType dataMember) {
            throw new NotImplementedException();
        }
        public object GetObjectValue(int index, ChartDataMemberType dataMember) {
            throw new NotImplementedException();
        }
    }
}
See Also