ChartCalculatedField.FieldName Property
Gets or sets the calculated field’s name.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v24.2.dll
NuGet Package: DevExpress.Wpf.Charts
#Declaration
#Property Value
Type | Description |
---|---|
String | The calculated field’s unique name. |
#Remarks
Use the FieldName property to specify the calculated field’s unique name. Avoid dots in names because the Chart uses dots to access data source members. Use the name to specify series data members (for example, Series.ArgumentDataMember, Series.ValueDataMember, Series.ToolTipHintDataMember, or Series.ColorDataMember). You can also use calculated field names to configure text patterns (for example, XYSeries2D.CrosshairLabelPattern.
#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;
}
}
}