Back to Devexpress

DiagramCoordinates.ArgumentScaleType Property

corelibraries-devexpress-dot-xtracharts-dot-diagramcoordinates.md

latest9.7 KB
Original Source

DiagramCoordinates.ArgumentScaleType Property

Gets the type of the argument scale.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public ScaleType ArgumentScaleType { get; }
vb
Public ReadOnly Property ArgumentScaleType As ScaleType

Property Value

TypeDescription
ScaleType

A ScaleType object, representing the scale type for the argument data of the data point.

|

Available values:

NameDescription
Qualitative

Identifies the Qualitative data scale. This means that data provided for the Series.Points will be treated as qualitative values and will be shown on the axis as textual representations (e.g., A , B , and C ).

| | Numerical |

Identifies the Numerical data scale. This means that data provided for the Series.Points will be treated as numerical values and will be shown on the axis as numbers (e.g., 100 , 200 , and 300 ).

| | DateTime |

Identifies the DateTime data scale. This means that data provided for the Series.Points will be treated as DateTime values and will be shown on the axis as DateTime values (e.g., January, 2003 , January, 2004 , and January, 2005 ). Note that in this case the AxisBase.DateTimeOptions property is used to define the output format of DateTime values shown on the axis.

| | TimeSpan |

Identifies the TimeSpan data scale. The data that you provide for the Series.Points will be treated and shown on the axis as TimeSpan values (for example, 00:00:00 , 00:00:01 , 00:00:02 ). Note that in this case, the axis’s TimeSpanScaleOptions property allows you to specify the scale-related settings. To define the output format of TimeSpan values shown on the axis, use the AxisBase.Label‘s TextPattern property.

| | Auto |

The scale type is automatically determined according to the real type of underlying data.

|

Example

The following example illustrates use of XYDiagram2D.PointToDiagram method for dragging the constant line with the mouse, and changing the series point values accordingly.

csharp
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace InteractiveConstantLine {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        Cursor defCursor;
        bool dragging = false;
        ChartControl chart;
        XYDiagram diagram;
        ConstantLine line;

        private void Form1_Load(object sender, EventArgs e) {
            this.chart = this.chartControl1;
            this.diagram = this.chart.Diagram as XYDiagram;
            this.line = this.diagram.AxisX.ConstantLines.GetConstantLineByName("ConstantLine1");

            // Add a title to the chart.
            ChartTitle chartTitle1 = new ChartTitle();
            chartTitle1.Text = "Drag the constant line...";
            this.chart.Titles.Add(chartTitle1);

        }

        private void chartControl1_MouseDown(object sender, MouseEventArgs e) {
            if (diagram == null)
                return;

            // Get the information about the clicked point.
            DiagramCoordinates coords = diagram.PointToDiagram(e.Location);

            // If the point is within the diagram and in the constant line ...
            if (!coords.IsEmpty && line.AxisValue is DateTime &&
                coords.DateTimeArgument.Equals((DateTime)line.AxisValue)) {

                // Allow dragging, catch the mouse and change the cursor.
                dragging = true;
                chart.Capture = true;
                SetCursor();
            }
        }

        private void chartControl1_MouseUp(object sender, MouseEventArgs e) {
            dragging = false;
            chart.Capture = false;
        }

        private void chartControl1_MouseMove(object sender, MouseEventArgs e) {
            if (diagram == null)
                return;

            if (dragging && (e.Button & MouseButtons.Left) == 0) {
                dragging = false;
                chart.Capture = false;
            }

            DiagramCoordinates coords = diagram.PointToDiagram(e.Location);
            if (coords.IsEmpty)
                RestoreCursor();
            else {
                if (dragging)
                    line.AxisValue = coords.DateTimeArgument;

                if (line.AxisValue is DateTime && coords.DateTimeArgument.Equals((DateTime)line.AxisValue))
                    SetCursor();
                else
                    RestoreCursor();
            }
        }
        void SetCursor() {
            if (defCursor == null)
                defCursor = Cursor.Current;
            Cursor.Current = Cursors.VSplit;
        }

        void RestoreCursor() {
            if (defCursor != null) {
                Cursor.Current = defCursor;
                defCursor = null;
            }
        }

    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts

Namespace InteractiveConstantLine
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private defCursor As Cursor
        Private dragging As Boolean = False
        Private chart As ChartControl
        Private diagram As XYDiagram
        Private line As ConstantLine

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            Me.chart = Me.chartControl1
            Me.diagram = TryCast(Me.chart.Diagram, XYDiagram)
            Me.line = Me.diagram.AxisX.ConstantLines.GetConstantLineByName("ConstantLine1")

            ' Add a title to the chart.
            Dim chartTitle1 As New ChartTitle()
            chartTitle1.Text = "Drag the constant line..."
            Me.chart.Titles.Add(chartTitle1)

        End Sub

        Private Sub chartControl1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles chartControl1.MouseDown
            If diagram Is Nothing Then
                Return
            End If

            ' Get the information about the clicked point.
            Dim coords As DiagramCoordinates = diagram.PointToDiagram(e.Location)

            ' If the point is within the diagram and in the constant line ...
            If (Not coords.IsEmpty) AndAlso TypeOf line.AxisValue Is Date AndAlso coords.DateTimeArgument.Equals(CDate(line.AxisValue)) Then

                ' Allow dragging, catch the mouse and change the cursor.
                dragging = True
                chart.Capture = True
                SetCursor()
            End If
        End Sub

        Private Sub chartControl1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles chartControl1.MouseUp
            dragging = False
            chart.Capture = False
        End Sub

        Private Sub chartControl1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles chartControl1.MouseMove
            If diagram Is Nothing Then
                Return
            End If

            If dragging AndAlso (e.Button And MouseButtons.Left) = 0 Then
                dragging = False
                chart.Capture = False
            End If

            Dim coords As DiagramCoordinates = diagram.PointToDiagram(e.Location)
            If coords.IsEmpty Then
                RestoreCursor()
            Else
                If dragging Then
                    line.AxisValue = coords.DateTimeArgument
                End If

                If TypeOf line.AxisValue Is Date AndAlso coords.DateTimeArgument.Equals(CDate(line.AxisValue)) Then
                    SetCursor()
                Else
                    RestoreCursor()
                End If
            End If
        End Sub
        Private Sub SetCursor()
            If defCursor Is Nothing Then
                defCursor = Cursor.Current
            End If
            Cursor.Current = Cursors.VSplit
        End Sub

        Private Sub RestoreCursor()
            If defCursor IsNot Nothing Then
                Cursor.Current = defCursor
                defCursor = Nothing
            End If
        End Sub

    End Class
End Namespace

See Also

DiagramCoordinates Class

DiagramCoordinates Members

DevExpress.XtraCharts Namespace