Back to Devexpress

Empty Points

wpf-401416-controls-and-libraries-charts-suite-chart-control-provide-data-empty-points.md

latest10.0 KB
Original Source

Empty Points

  • Sep 03, 2021
  • 7 minutes to read

This topic explains what Empty Points are, how the Chart Control processes empty points, and how to add such a point to a chart.

Run Demo: Empty Points

Empty points are points with undefined values. You can use empty points to insert gaps between series point values. The Chart displays empty points as breaks in continuous series (for example, Line or Area), and missing points or bars in discrete series (for example, Bars or Points). Empty points in the Pie, Donut, and Funnel series are skipped.

Line Series

Spline Area Series

Bar Series

Point Series

The following table contains data for the charts above:

DatePoliticsEntertainmentTravel
01-Jan-19655645
02-Jan-19784540
03-Jan-19957056
04-Jan-191108247
05-Jan-191088038
06-Jan-19522031
07-Jan-19461027
08-Jan-197027
09-Jan-198642
10-Jan-199265
11-Jan-191084537
12-Jan-191155621
13-Jan-19751010
14-Jan-196505

To create an empty point, execute one of the following actions:

  • Set a point’s value to NaN if you use the Chart Designer to add points to a series.

  • Leave a value undefined if you add points in markup.

  • Use the SeriesPoint‘s class constructors that take only an argument as a parameter if you add points to a series in code.

  • Or set a data point’s numeric value to Double.NaN(or Single.NaN) in a data source. If a series point has a date-time value, use the DateTime.MinValue value. Use TimeSpan.Zero for the time-span series point values.

The Chart Control does not display series labels, tooltips, and the crosshair cursor label for empty points.

Missing points (points that do not exist for particular axis arguments) are represented as empty points if the ProcessMissingPoints (NumericAggregationScaleOptionsBase.ProcessMissingPoints, DateTimeAggregationScaleOptionsBase.ProcessMissingPoints or TimeSpanAggregationScaleOptionsBase.ProcessMissingPoints) property is set to InsertEmptyPoints.

Tip

Define How to Handle Empty Points

Use a series’s EmptyPointOptions property to access empty point settings. Specify the EmptyPointOptions.ProcessPoints property to select the manner in which the chart control should handle empty points.

For example, use the following code to display points with predicted values instead of empty points.

xaml
<dxc:BarSideBySideSeries2D ...>
    <dxc:BarSideBySideSeries2D.EmptyPointOptions>
        <dxc:EmptyPointOptions ProcessPoints="Interpolate" Brush="#80808080"/>
    </dxc:BarSideBySideSeries2D.EmptyPointOptions>
</dxc:BarSideBySideSeries2D>

Customize Appearance of Empty Points

Appearance settings of empty points depends on the series type. Depending on the series, set the EmptyPointOptions property value to one of the following types and configure empty point appearance settings:

The example below configures empty point appearance for line, area, and bar series. Empty points are painted gray:

xaml
<dxc:LineSeries2D DisplayName="Day Temperature" ...>
    <dxc:LineSeries2D.EmptyPointOptions>
        <dxc:LineEmptyPointOptions ProcessPoints="Interpolate" 
                                   Brush="#808080">
            <dxc:LineEmptyPointOptions.LineStyle>
                <dxc:LineStyle Thickness="1" >
                    <dxc:LineStyle.DashStyle>
                        <DashStyle Dashes="2 2"/>
                    </dxc:LineStyle.DashStyle>
                </dxc:LineStyle>
            </dxc:LineEmptyPointOptions.LineStyle>
        </dxc:LineEmptyPointOptions>
    </dxc:LineSeries2D.EmptyPointOptions>
</dxc:LineSeries2D>
<dxc:AreaSeries2D DisplayName="Wind" ...>
    <dxc:AreaSeries2D.EmptyPointOptions>
        <dxc:AreaEmptyPointOptions ProcessPoints="Interpolate" 
                                   Brush="#80808080">
            <dxc:AreaEmptyPointOptions.Border>
                <dxc:SeriesBorder Brush="DarkGray"/>
            </dxc:AreaEmptyPointOptions.Border>
        </dxc:AreaEmptyPointOptions>
    </dxc:AreaSeries2D.EmptyPointOptions>
</dxc:AreaSeries2D>
<dxc:BarSideBySideSeries2D DisplayName="Pressure" ...>
    <dxc:BarSideBySideSeries2D.EmptyPointOptions>
        <dxc:EmptyPointOptions ProcessPoints="Interpolate" 
                               Brush="#80808080"/>
    </dxc:BarSideBySideSeries2D.EmptyPointOptions>
</dxc:BarSideBySideSeries2D>

Show Isolated Points

The Chart does not draw a point between two empty points. To display a point in this case, enable the ShowIsolatedPoints (LineSeries2D.ShowIsolatedPoints or CircularLineSeries2D.ShowIsolatedPoints) property.

ShowIsolatedPoints = trueShowIsolatedPoints = false
xaml
<dxc:ChartControl>
    <dxc:XYDiagram2D>
        <dxc:LineSeries2D ShowIsolatedPoints="True">
            <dxc:SeriesPoint Argument="A" Value="5"/>
            <dxc:SeriesPoint Argument="B" Value="6"/>
            <dxc:SeriesPoint Argument="C" />
            <dxc:SeriesPoint Argument="D" Value="4"/> <!-- This point is isolated. -->
            <dxc:SeriesPoint Argument="E" />
            <dxc:SeriesPoint Argument="F" Value="6"/>
            <dxc:SeriesPoint Argument="G" Value="8"/>
            <dxc:SeriesPoint Argument="H" Value="7"/>
        </dxc:LineSeries2D>
    </dxc:XYDiagram2D>
</dxc:ChartControl>