Back to Devexpress

Series3DDataSourceAdapter.CalculatedFields Property

wpf-devexpress-dot-xpf-dot-charts-dot-series3ddatasourceadapter-755a052b.md

latest6.6 KB
Original Source

Series3DDataSourceAdapter.CalculatedFields Property

Returns a collection of calculated fields.

Namespace : DevExpress.Xpf.Charts

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

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public ChartCalculatedFieldCollection CalculatedFields { get; }
vb
Public ReadOnly Property CalculatedFields As ChartCalculatedFieldCollection

Property Value

TypeDescription
ChartCalculatedFieldCollection

A collection that stores calculated fields.

|

Remarks

Calculated fields allow you to evaluate values based on an expression and use them as a data source for series arguments, values, crosshair labels, and so on.

To add a calculated field to a Chart3D Control, add a ChartCalculatedField object to the adapter’s CalculatedFields collection and specify its parameters.

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: [X] * [Y].

xaml
<dxc:Chart3DControl AspectRatio="1 1 0.5">
    <dxc:Chart3DControl.DataContext>
        <local:ChartViewModel/>
    </dxc:Chart3DControl.DataContext>
    <dxc:Series3DDataSourceAdapter SeriesDataMember="Name" 
                                   XArgumentDataMember="X" 
                                   YArgumentDataMember="Y" 
                                   ValueDataMember="Value" 
                                   DataSource="{Binding DataPoints}">
        <dxc:Series3DDataSourceAdapter.CalculatedFields>
            <dxc:ChartCalculatedField FieldName="Value" 
                                      Expression="[X]*[Y]" 
                                      FieldType="Double"/>
        </dxc:Series3DDataSourceAdapter.CalculatedFields>
        <dxc:Series3DDataSourceAdapter.SeriesTemplate>
            <dxc:Series3DTemplate>
                <dxc:Series3DTemplate.View>
                    <dxc:Point3DSeriesView/>
                </dxc:Series3DTemplate.View>
            </dxc:Series3DTemplate>
        </dxc:Series3DDataSourceAdapter.SeriesTemplate>
    </dxc:Series3DDataSourceAdapter>
</dxc:Chart3DControl>
csharp
using System.Collections.Generic;
using System.Windows;
namespace Chart3DCalculatedFields {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
    }
    public class ChartViewModel {
        List<DataPoint> dataPoints;
        public List<DataPoint> DataPoints {
            get {
                if (dataPoints == null) {
                    dataPoints = new List<DataPoint> {
                            new DataPoint ("Series1", 12, 10),
                            new DataPoint ("Series1", 11.2, 11.46),
                            new DataPoint ("Series1", 13.1, 11.90),
                            new DataPoint ("Series1", 10.74, 12.1),
                            new DataPoint ("Series1", 9.6, 12.236),
                            new DataPoint ("Series1", 10.2, 12.325),
                            new DataPoint ("Series2", 13.9, 12.625),
                            new DataPoint ("Series2", 11.4, 13.896),
                            new DataPoint ("Series2", 13.7, 14.123),
                            new DataPoint ("Series2", 15.4, 14.623),
                            new DataPoint ("Series2", 13.9, 15.007),
                            new DataPoint ("Series2", 13, 15.452),
                            new DataPoint ("Series2", 12.56, 15.756)
                };
                }
                return dataPoints;
            }
        }
    }
    public class DataPoint {
        public double X { get; set; }
        public double Y { get; set; }
        public string Name { get; set; }
        public DataPoint(string name, double x, double y) {
            this.Name = name;
            this.X = x;
            this.Y = y;
        }
    }
}
vb
Imports System.Collections.Generic
Imports System.Windows
Namespace Chart3DCalculatedFields
    Public Partial Class MainWindow
        Inherits Window
        Public Sub New()
            InitializeComponent()
        End Sub
    End Class
    Public Class ChartViewModel
        Private f_DataPoints As List(Of DataPoint)
        Public ReadOnly Property DataPoints As List(Of DataPoint)
            Get
                If f_DataPoints Is Nothing Then
                    f_DataPoints = New List(Of DataPoint) From {
                        New DataPoint("Series1", 12, 10),
                        New DataPoint("Series1", 11.2, 11.46),
                        New DataPoint("Series1", 13.1, 11.90),
                        New DataPoint("Series1", 10.74, 12.1),
                        New DataPoint("Series1", 9.6, 12.236),
                        New DataPoint("Series1", 10.2, 12.325),
                        New DataPoint("Series2", 13.9, 12.625),
                        New DataPoint("Series2", 11.4, 13.896),
                        New DataPoint("Series2", 13.7, 14.123),
                        New DataPoint("Series2", 15.4, 14.623),
                        New DataPoint("Series2", 13.9, 15.007),
                        New DataPoint("Series2", 13, 15.452),
                        New DataPoint("Series2", 12.56, 15.756)
                    }
                End If
                Return f_DataPoints
            End Get
        End Property
    End Class
    Public Class DataPoint
        Public Property X As Double
        Public Property Y As Double
        Public Property Name As String
        Public Sub New(ByVal name As String, ByVal x As Double, ByVal y As Double)
            Me.Name = name
            Me.X = x
            Me.Y = y
        End Sub
    End Class
End Namespace

See Also

Series3DDataSourceAdapter Class

Series3DDataSourceAdapter Members

DevExpress.Xpf.Charts Namespace