Back to Devexpress

Chart Clients for the Range Control

wpf-16847-controls-and-libraries-charts-suite-chart-control-chart-clients-for-the-range-control.md

latest15.2 KB
Original Source

Chart Clients for the Range Control

  • Aug 28, 2024
  • 6 minutes to read

This document lists the chart client types and explains how to use them in a Range control.

Chart Clients are used to visualize numeric or date-time data within the range control’s viewport. Clients interact with the Range control via the IRangeControlClient interface.

Chart Range Control Clients are divided into two groups:

Common Information

The Client uses one of the following views to represent data when data is bound to a Client directly and when data is provided from the Chart’s series:

View TypeImageDescription
RangeControlClientAreaViewAn area chart.
RangeControlClientBarViewA bar chart.
RangeControlClientLineViewA line chart.

Note

Chart clients show an Area view by default.

The following dependency properties configure Chart Range Control Client appearance:

PropertyDescription
ChartRangeControlClientBase.ShowGridLinesGets or sets a value indicating whether the grid lines should be visible in the chart range control client. This is a dependency property.
ChartRangeControlClientBase.ShowArgumentLabelsGets or sets a value that specifies whether to show a data point’s argument label in the chart range control client. This is a dependency property.
ChartRangeControlClientBase.GridLinesBrushGets or sets chart client grid lines’ color. This is a dependency property.
ChartRangeControlClientBase.ArgumentLabelTemplateGets or sets the argument label template. This is a dependency property.

Standalone Chart Range Control Clients

A Standalone Chart Range Control Client uses its ItemsSource property to draw a chart in the Range Control. The following standalone chart clients are available:

See the Range Control section for more information.

To add a chart client (numeric chart client or date-time chart client) to the Range control, do one of the following:

After adding the numeric chart client, your XAML should appear as follows:

xaml
<Window  
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Custom="http://schemas.devexpress.com/winfx/2008/xaml/charts/rangecontrolclient"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="NumericRangeControlClient.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxe:RangeControl>
            <dxe:RangeControl.Client>
                <Custom:NumericChartRangeControlClient/>
            </dxe:RangeControl.Client>
        </dxe:RangeControl>
    </Grid>
</Window>

The RangeControl.Client property is automatically set to NumericChartRangeControlClient (or DateTimeChartRangeControlClient).

To display data in chart clients, you need to bind the client to a data source using the following properties:

MemberDescription
ChartRangeControlClient.ItemsSourceGets or sets the chart client’s data source.
ChartRangeControlClient.ArgumentDataMemberGets or sets the name of the data field that contains the chart client’s point arguments.
ChartRangeControlClient.ValueDataMemberGets or sets the name of the data field that contains the chart client’s point values.

Note

When you bind a numeric chart range control client to simple type objects (short, integer, long, double, decimal, float types, etc.), for example, to an array of simple objects, you do not need to use ChartRangeControlClient.ArgumentDataMember and ChartRangeControlClient.ValueDataMember properties. In this case, the numeric chart client automatically treats simple type objects’ values as chart values. As a result, the data values are shown in the same order in which elements are added to the array.

Specify the ChartRangeControlClient.ArgumentDataMember property if you need to display numeric points sorted by arguments in the ascending order, for example, from the collection.

To assign a view type to a numeric chart client or date-time chart client, set its ChartRangeControlClient.View property to the RangeControlClientView descendant representing the current chart view.

See the following examples to learn more about how to use the chart client for the range control:

Chart Range Control Client bound to a Chart Control

The Chart Bound Range Control Client displays data from chart series in a Range Control and allows scrolling and zooming a chart. The Range control can visualize only the primary axes data of the bound chart.

The following code demonstrates how to configure the Chart Bound Range Control Client’s behavior:

xaml
<dxe:RangeControl AllowZoom="False">
    <dxcr:ChartBoundRangeControlClient Chart="{Binding ElementName=chart}" ThumbLabelFormatString="{}{0:dd MMM yyyy}">
        <dxcr:ScaleOptions LabelFormat="{}{0:MMM yyyy}">
            <dxcr:ScaleOptions.GridBehavior>
                <dxcr:ManualGridBehavior Alignment="Month" Spacing="20"/>
            </dxcr:ScaleOptions.GridBehavior>
            <dxcr:ScaleOptions.SnapBehavior>
                <dxcr:AutoSnapBehavior/>
            </dxcr:ScaleOptions.SnapBehavior>
        </dxcr:ScaleOptions>
    </dxcr:ChartBoundRangeControlClient>
</dxe:RangeControl>

The code above uses the following classes and members:

SymbolsDescription
ChartBoundRangeControlClientThe Chart Range Control Client that obtains data to visualize from the bound Chart Control.
ChartBoundRangeControlClient.ScaleOptionsGets or sets the scale options that configure grid appearance. This is a dependency property.
ScaleOptionsThe Chart bound Range Control scale options storage.
ScaleOptions.LabelFormatGets or sets the string used to format chart client label values. This is a dependency property.
ScaleOptions.GridBehaviorGets or sets the behavior that specifies how the Chart bound Range Control Client forms its grid. This is a dependency property.
ScaleOptions.SnapBehaviorGets or sets the behavior that specifies how the Chart bound Range Control Client snaps its range bounds. This is a dependency property.

The Chart Bound Client can use one of the following Grid Behaviors :

BehaviorSample ImageDescription
AutoGridBehaviorIdentifies the Chart bound Range Control Client Grid Behavior , in which the Client automatically calculates its grid spacing, grid offset and grid alignment (for the date-time scale) values.
ChartGridBehaviorIdentifies the Chart bound Range Control Client Grid Behavior which obtains the Client’s grid spacing and grid offset and, grid alignment (for the date-time scale) values from the bound chart.
ManualGridBehaviorIdentifies the Chart bound Range Control Client Grid Behavior which forms Client’s grid using ManualGridBehavior.Offset, ManualGridBehavior.Spacing and ManualGridBehavior.Alignment (for the date-time scale) values.

The following predefined Snap Behaviors specifies how the Range control’s selected range is aligned:

BehaviorSample ImageDescription
AutoSnapBehaviorIdentifies the Chart bound Range Control Client’s Snap Behavior , in which the selected range snaps to the Client’s grid.
ChartSnapBehaviorThe Chart Snap Behavior specifies that the Range control’s selected range is aligned by the bound chart’s measurement.
ManualSnapBehaviorChart bound Range Control Client Snap Behavior , in which the selected range is aligned using parameters that the behavior specifies manually via the ManualSnapBehavior.Offset, ManualSnapBehavior.Spacing, ManualSnapBehavior.Alignment (for date-time scale) properties.

To configure how a Range Control Client displays the bound Chart’s series, use the following code:

xaml
<dxc:StockSeries2D DisplayName="EURUSD" DataSource="{Binding EurUsdRates}" 
                   ArgumentDataMember="TimeStamp" ValueDataMember="Rate">
     <dxc:StockSeries2D.RangeControlOptions>
        <dxcr:RangeControlOptions ValueLevel="Close">
            <dxcr:RangeControlOptions.View>
                <dxcr:RangeControlClientLineView ShowMarkers="False"/>
            </dxcr:RangeControlOptions.View>
        </dxcr:RangeControlOptions>
     </dxc:StockSeries2D.RangeControlOptions>
</dxc:StockSeries2D>

The following classes and members allow to configure the appearance of a series within the Range Control:

SymbolsDescription
XYSeries2D.RangeControlOptionsGets or sets options that specify how the Range control visualizes the series data.
RangeControlOptionsThe storage of settings that specify series appearance in the Range Control.
RangeControlOptions.VisibleGets or sets the value indicating whether the Range Control visualized the series data. This is a dependency property.
RangeControlOptions.ViewGets or sets the view that configures the series’ appearance within the Range Control. This is a dependency property.