Back to Devexpress

ActualScaleType Enum

corelibraries-devexpress-dot-xtracharts-71f5f529.md

latest10.7 KB
Original Source

ActualScaleType Enum

Lists scale types for series point arguments and values.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[ResourceFinder(typeof(XtraChartsResFinder), "PropertyNamesRes")]
public enum ActualScaleType
vb
<ResourceFinder(GetType(XtraChartsResFinder), "PropertyNamesRes")>
Public Enum ActualScaleType

Members

NameDescription
Qualitative

Identifies the qualitative data scale. This means that data used to create series points is treated as string categories and shown on the axis as string values (for example, A , B , C ). This scale type is only available for arguments. Use the AxisXBase.QualitativeScaleOptions property to access settings of an axis with the qualitative scale.

| | Numerical |

Identifies the numeric data scale. This means that data used to create series points is treated as numeric values and shown on the axis as numbers (for example, 100 or 0.5 ). Use the AxisBase.NumericScaleOptions property to access settings of an axis with the numeric scale. For example, define an axis’s NumericScaleOptions.Label.TextPattern property to specify the display format of axis labels.

| | DateTime |

Identifies the DateTime data scale. This means that data used to create series points is treated as DateTime values and shown on the axis as DateTime values (for example, January, 2003 or 2013/01/07 ). Use the AxisBase.DateTimeScaleOptions property to access settings of an axis with the date-time scale. For example, define an axis’s DateTimeScaleOptions.Label.TextPattern property to specify the display format of axis labels.

| | TimeSpan |

Identifies the TimeSpan data scale. This means that data used to create series points is treated as TimeSpan values and shown on the axis as TimeSpan values (for example, 00:00:00 , 00:00:01 , 00:00:02 ). Use the AxisBase.TimeSpanScaleOptions property to access settings of an axis with the time-span scale. For example, define an axis’ TimeSpanScaleOptions.Label.TextPattern property to specify the display format of axis labels.

|

Example

How to: Implement a Custom Chart Data Adapter

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

csharp
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();
        }
    }
}
vb
Imports DevExpress.XtraCharts

Namespace CustomDataAdapter
    Partial Public Class Form1
        Inherits Form

        Private Const DataItemCount As Long = 100000
        Private Const Max As Integer = 100
        Private Const Min As Integer = 80
        Private rand As New Random()
        Public Sub New()
            InitializeComponent()

            Dim series As New Series("Series", ViewType.Line)
            chartControl1.Series.Add(series)

            Dim dataItems As New List(Of DataItem)()
            For i As Integer = 0 To DataItemCount - 1
                dataItems.Add(New DataItem(i, rand.NextDouble() * (Max - Min) + Max))
            Next i

            series.DataAdapter = New CustomNumericDataAdapter(dataItems)

            CType(chartControl1.Diagram, XYDiagram).AxisY.WholeRange.AlwaysShowZeroLevel = False
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        End Sub
    End Class
    Public Class DataItem
        Public ReadOnly Property Argument() As Double
        Public ReadOnly Property Value() As Double
        Public Sub New(ByVal argument As Double, ByVal value As Double)
            Me.Argument = argument
            Me.Value = value
        End Sub
    End Class
    Public Class CustomNumericDataAdapter
        Implements ISeriesAdapter

        Private ReadOnly items As IList(Of DataItem)
        Public ReadOnly Property DataSorted() As Boolean Implements DevExpress.XtraCharts.IChartDataAdapter.DataSorted
            Get
                Return True
            End Get
        End Property
        Public ReadOnly Property ItemsCount() As Integer Implements DevExpress.XtraCharts.IChartDataAdapter.ItemsCount
            Get
                Return Me.items.Count
            End Get
        End Property
        Public Sub New(ByVal items As IList(Of DataItem))
            Me.items = items
        End Sub
        Private Custom Event DataChanged As NotifyChartDataChangedEventHandler Implements IChartDataAdapter.DataChanged
            AddHandler(ByVal value As NotifyChartDataChangedEventHandler)
            End AddHandler
            RemoveHandler(ByVal value As NotifyChartDataChangedEventHandler)
            End RemoveHandler
            RaiseEvent(ByVal sender As System.Object, ByVal e As DevExpress.XtraCharts.ChartDataUpdateEventArgs)
            End RaiseEvent
        End Event
        Public Function Clone() As Object Implements System.ICloneable.Clone
            Return Me
        End Function
        Public Function GetNumericalValue(ByVal index As Integer, ByVal dataMember As ChartDataMemberType) As Double Implements DevExpress.XtraCharts.IChartDataAdapter.GetNumericalValue
            Select Case dataMember
                Case ChartDataMemberType.Argument
                    Return items(index).Argument
                Case ChartDataMemberType.Value
                    Return items(index).Value
            End Select
            Return Double.NaN
        End Function
        Public Function GetSourceObject(ByVal index As Integer) As Object Implements DevExpress.XtraCharts.IChartDataAdapter.GetSourceObject
            Return Me.items(index)
        End Function
        Public Function GetScaleType(ByVal dataMember As ChartDataMemberType) As ActualScaleType Implements DevExpress.XtraCharts.IChartDataAdapter.GetScaleType
            Return ActualScaleType.Numerical
        End Function
        Public Function GetDateTimeValue(ByVal index As Integer, ByVal dataMember As ChartDataMemberType) As Date Implements DevExpress.XtraCharts.IChartDataAdapter.GetDateTimeValue
            Throw New NotImplementedException()
        End Function
        Public Function GetQualitativeValue(ByVal index As Integer, ByVal dataMember As ChartDataMemberType) As String Implements DevExpress.XtraCharts.IChartDataAdapter.GetQualitativeValue
            Throw New NotImplementedException()
        End Function
        Public Function GetTimeSpanValue(ByVal index As Integer, ByVal dataMember As ChartDataMemberType) As TimeSpan Implements DevExpress.XtraCharts.IChartDataAdapter.GetTimeSpanValue
            Throw New NotImplementedException()
        End Function
        Public Function GetObjectValue(ByVal index As Integer, ByVal dataMember As ChartDataMemberType) As Object Implements DevExpress.XtraCharts.IChartDataAdapter.GetObjectValue
            Throw New NotImplementedException()
        End Function
    End Class
End Namespace

See Also

DevExpress.XtraCharts Namespace