Back to Devexpress

NumericChartRangeControlClientRange Class

windowsforms-devexpress-dot-xtraeditors-0ce9bd88.md

latest9.9 KB
Original Source

NumericChartRangeControlClientRange Class

Contains the common settings that define the range displayed by a numeric chart client of the range control.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public class NumericChartRangeControlClientRange :
    ChartRangeControlClientRange
vb
Public Class NumericChartRangeControlClientRange
    Inherits ChartRangeControlClientRange

The following members return NumericChartRangeControlClientRange objects:

Remarks

The options provided by the NumericChartRangeControlClientRange class allow you to limit a chart client range manually, by specifying both the minimum and maximum axis value. This can be done via the NumericChartRangeControlClientRange.Min and NumericChartRangeControlClientRange.Max properties.

Note that the range of the numeric chart client is calculated automatically (the ChartRangeControlClientGridOptions.Auto property is set to true ) by default. When you define the custom range, this resets the auto range calculation.

Example

This example shows how to bind a numeric chart range control client to a System.Collections.Generic.List containing NumericItem objects.

In order to provide data to a chart numeric range control client, you need to access the ChartRangeControlClientDataProvider object using the ChartRangeControlClientBase.DataProvider property and assign a data source to the ChartRangeControlClientDataProvider.DataSource property.

Each NumericItem object contains Argument, Value and Series properties, to which a numeric chart range control client is bound via its ChartRangeControlClientDataProvider.ArgumentDataMember, ChartRangeControlClientDataProvider.ValueDataMember, and ChartRangeControlClientDataProvider.SeriesDataMember (optional) properties.

In addition, this example shows how to customize chart client common settings (e.g., change the numeric range, customize template view and grid options).

csharp
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace NumericChartClient {
    public partial class Form1 : Form {

        const int pointCount = 20;
        const int seriesCount = 2;
        Random rand = new Random();
        List<NumericItem> data = new List<NumericItem>();

        public Form1() {
            InitializeComponent();

            // Assign a numeric chart client to the Range control. 
            rangeControl1.Client = numericChartRangeControlClient1;

            // Generate a list of NumericItem objects and bind the numeric chart client to it.
            numericChartRangeControlClient1.DataProvider.DataSource = GenerateNumericData();

            // Specify data members to bind the chart client.
            numericChartRangeControlClient1.DataProvider.ArgumentDataMember = "Argument";
            numericChartRangeControlClient1.DataProvider.ValueDataMember = "Value";
            numericChartRangeControlClient1.DataProvider.SeriesDataMember = "Series";

            // Specify the chart range control client view.
            AreaChartRangeControlClientView areaView = new AreaChartRangeControlClientView();
            numericChartRangeControlClient1.DataProvider.TemplateView = areaView;

            // Customize the area view appearance. 
            areaView.AreaOpacity = 90;
            areaView.Color = Color.Gray;
            areaView.ShowMarkers = true;
            areaView.MarkerSize = 5;
            areaView.MarkerColor = Color.Red;

            // Specify the palette name to get a nice-looking chart.
            numericChartRangeControlClient1.PaletteName = "NatureColors";

            // Change the default range of the numeric chart range control client.          
            numericChartRangeControlClient1.Range.Min = 4;
            numericChartRangeControlClient1.Range.Max = 12;

            // Customize the grid options of the numeric chart range control client.          
            numericChartRangeControlClient1.GridOptions.GridSpacing = 2;
            numericChartRangeControlClient1.GridOptions.SnapSpacing = 1;
        }

        List<NumericItem> GenerateNumericData() {

            for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
                for (int i = 0; i < pointCount; i++) {
                    data.Add(new NumericItem() {
                        Argument = i,
                        Value = rand.Next(0, 30) + i,
                        Series = seriesIndex
                    });
                }
            }
            return data;
        }
    }

    public class NumericItem {
        public double Argument { get; set; }
        public double Value { get; set; }
        public double Series { get; set; }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraEditors

Namespace NumericChartClient
    Partial Public Class Form1
        Inherits Form

        Private Const pointCount As Integer = 20
        Private Const seriesCount As Integer = 2
        Private rand As New Random()
        Private data As New List(Of NumericItem)()

        Public Sub New()
            InitializeComponent()

            ' Assign a numeric chart client to the Range control. 
            rangeControl1.Client = numericChartRangeControlClient1

            ' Generate a list of NumericItem objects and bind the numeric chart client to it.
            numericChartRangeControlClient1.DataProvider.DataSource = GenerateNumericData()

            ' Specify data members to bind the chart client.
            numericChartRangeControlClient1.DataProvider.ArgumentDataMember = "Argument"
            numericChartRangeControlClient1.DataProvider.ValueDataMember = "Value"
            numericChartRangeControlClient1.DataProvider.SeriesDataMember = "Series"

            ' Specify the chart range control client view.
            Dim areaView As New AreaChartRangeControlClientView()
            numericChartRangeControlClient1.DataProvider.TemplateView = areaView

            ' Customize the area view appearance. 
            areaView.AreaOpacity = 90
            areaView.Color = Color.Gray
            areaView.ShowMarkers = True
            areaView.MarkerSize = 5
            areaView.MarkerColor = Color.Red

            ' Specify the palette name to get a nice-looking chart.
            numericChartRangeControlClient1.PaletteName = "NatureColors"

            ' Change the default range of the numeric chart range control client.          
            numericChartRangeControlClient1.Range.Min = 4
            numericChartRangeControlClient1.Range.Max = 12

            ' Customize the grid options of the numeric chart range control client.          
            numericChartRangeControlClient1.GridOptions.GridSpacing = 2
            numericChartRangeControlClient1.GridOptions.SnapSpacing = 1
        End Sub

        Private Function GenerateNumericData() As List(Of NumericItem)

            For seriesIndex As Integer = 0 To seriesCount - 1
                For i As Integer = 0 To pointCount - 1
                    data.Add(New NumericItem() With {.Argument = i, .Value = rand.Next(0, 30) + i, .Series = seriesIndex})
                Next i
            Next seriesIndex
            Return data
        End Function
    End Class

    Public Class NumericItem
        Private privateArgument As Double
        Public Property Argument() As Double
            Get
                Return privateArgument
            End Get
            Set(ByVal value As Double)
                privateArgument = value
            End Set
        End Property
        Private privateValue As Double
        Public Property Value() As Double
            Get
                Return privateValue
            End Get
            Set(ByVal value As Double)
                privateValue = value
            End Set
        End Property
        Private privateSeries As Double
        Public Property Series() As Double
            Get
                Return privateSeries
            End Get
            Set(ByVal value As Double)
                privateSeries = value
            End Set
        End Property
    End Class
End Namespace

Inheritance

Object ChartRangeControlClientRange NumericChartRangeControlClientRange

See Also

NumericChartRangeControlClientRange Members

DevExpress.XtraEditors Namespace