Skip to main content

ITimeSpanMeasureUnitsCalculator.CalculateMeasureUnit(IEnumerable<Series>, Double, Int32, Double, Double, Double, Double) Method

Calculates the date-time measurement unit that an axis should use for display.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v21.2.dll

Declaration

TimeSpanMeasureUnit CalculateMeasureUnit(
    IEnumerable<Series> series,
    double axisLength,
    int pixelsPerUnit,
    double visualMin,
    double visualMax,
    double wholeMin,
    double wholeMax
)

Parameters

Name Type Description
series IEnumerable<Series>

All Series associated with the axis.

axisLength Double

The length of the axis’s visual range in pixels.

pixelsPerUnit Int32

The minimum count of pixels that series require to draw their points correctly.

visualMin Double

The visual range’s minimum value in milliseconds.

visualMax Double

The visual range’s maximum value in milliseconds.

wholeMin Double

The whole range’s minimum value in milliseconds.

wholeMax Double

The whole range’s maximum value in milliseconds.

Returns

Type Description
TimeSpanMeasureUnit

The calculated measurement unit.

Remarks

Bars can overlap each other if the calculated measurement unit covers fewer pixels on the axis than the pixelPerUnit parameter specifies.

Example

The automatic time-span scale options allow you to create a measurement unit calculator to determine the current measurement unit if the predefined one does not fit your requirements. Create a class that implements the ITimeSpanMeasureUnitsCalculator interface and assign it to the AutomaticMeasureUnitsCalculator property to use a custom measurement units calculation algorithm:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TimeSpanExample"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
        x:Class="TimeSpanExample.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.DataContext>
        <local:ChartViewModel/>
    </Window.DataContext>
    <Grid>
        <dxc:ChartControl>
            <dxc:XYDiagram2D>
                <dxc:XYDiagram2D.AxisX>
                    <dxc:AxisX2D>
                        <dxc:AxisX2D.TimeSpanScaleOptions>
                            <dxc:AutomaticTimeSpanScaleOptions AggregateFunction="Average">
                                <dxc:AutomaticTimeSpanScaleOptions.AutomaticMeasureUnitsCalculator>
                                    <local:CustomAutomaticTimeSpanMeasureUnitsCalculator/>
                                </dxc:AutomaticTimeSpanScaleOptions.AutomaticMeasureUnitsCalculator>
                            </dxc:AutomaticTimeSpanScaleOptions>
                        </dxc:AxisX2D.TimeSpanScaleOptions>
                    </dxc:AxisX2D>
                </dxc:XYDiagram2D.AxisX>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>
</Window>
See Also