Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ChartCalculatedFieldCollection Class

A collection that stores calculated fields.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v24.2.dll

NuGet Package: DevExpress.Wpf.Charts

#Declaration

public class ChartCalculatedFieldCollection :
    ChartElementCollection<ChartCalculatedField>,
    IEnumerable<ICalculatedField>,
    IEnumerable

The following members return ChartCalculatedFieldCollection objects:

#Remarks

The ChartCalculatedFieldCollection is a collection of the ChartCalculatedField objects.

#Example

The following example shows how to create a calculated field and then use this field as a data source for a series. The field’s values are calculated by the following expression: [Time.Seconds] * [Velocity].

using System;
using System.Collections.Generic;
using System.Windows;

namespace CalculatedFields {
    public class ChartViewModel {
        List<DataPoint> dataPoints;
        public List<DataPoint> DataPoints {
            get {
                if (dataPoints == null) {
                    dataPoints = new List<DataPoint> {
                            new DataPoint (new TimeSpan(0, 0, 0), 10),
                            new DataPoint (new TimeSpan(0, 0, 1), 11.46),
                            new DataPoint (new TimeSpan(0, 0, 2), 11.90),
                            new DataPoint (new TimeSpan(0, 0, 3), 12.1),
                            new DataPoint (new TimeSpan(0, 0, 4), 12.236),
                            new DataPoint (new TimeSpan(0, 0, 5), 12.325),
                            new DataPoint (new TimeSpan(0, 0, 6), 12.625),
                            new DataPoint (new TimeSpan(0, 0, 7), 13.896),
                            new DataPoint (new TimeSpan(0, 0, 8), 14.123),
                            new DataPoint (new TimeSpan(0, 0, 9), 14.623),
                            new DataPoint (new TimeSpan(0, 0, 10), 15.007),
                            new DataPoint (new TimeSpan(0, 0, 11), 15.452),
                            new DataPoint (new TimeSpan(0, 0, 12), 15.756)
                };
                }
                return dataPoints;
            }
        }
    }
    public class DataPoint {
        public TimeSpan Time { get; set; }
        public double Velocity { get; set; }
        public DataPoint(TimeSpan time, double velocity) {
            this.Time = time;
            this.Velocity = velocity;
        }
    }
}
See Also