Skip to main content

Empty Points

  • 8 minutes to read

Empty points are points with undefined Values. This document describes how the Chart Control processes empty points.

Run Demo: Empty Points

The Chart displays empty points as breaks in the Line or Area series views, and missing points or bars in other series view types.

The following table contains data for the charts above:

Date Politics Entertainment Travel
01-Nov-16 65 56 45
02-Nov-16 78 45 40
03-Nov-16 95 70 56
04-Nov-16 110 82 47
05-Nov-16 108 80 38
06-Nov-16 52 20 31
07-Nov-16 46 10 27
08-Nov-16 70 27
09-Nov-16 86 42
10-Nov-16 92 65
11-Nov-16 108 45 37
12-Nov-16 115 56 21
13-Nov-16 75 10 10
14-Nov-16 65 0 5

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

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

    using DevExpress.XtraCharts;
    using System;
    using System.Collections.Generic;
    namespace SampleChart {
        public partial class WebForm1 : System.Web.UI.Page {
            protected void Page_Load(object sender, EventArgs e) {
                chartControl.DataSource = WeatherDataProvider.Data;
                Series series = new Series("Series", ViewType.Line);
                chartControl.Series.Add(series);
                series.Points.Add(new SeriesPoint(new DateTime(2020, 7, 9), 5));
                // The following line adds an empty series point to a series.
                series.Points.Add(new SeriesPoint(new DateTime(2020, 7, 10)));
                series.Points.Add(new SeriesPoint(new DateTime(2020, 7, 11), 7));
            }
        }
    }
    
  • Set a data point’s value to Double.NaN or leave it unspecified in a data source.

    using DevExpress.XtraCharts;
    using System;
    using System.Collections.Generic;
    namespace SampleChart {
        public partial class WebForm1 : System.Web.UI.Page {
            protected void Page_Load(object sender, EventArgs e) {
                chartControl.DataSource = WeatherDataProvider.Data;
                Series series = new Series("Wind", ViewType.Line);
                series.SetDataMembers("Date", "Wind");
                chartControl.Series.Add(series);
                chartControl.DataBind();
            }
        }
        public static class WeatherDataProvider {
            static List<WeatherPoint> data;
            public static List<WeatherPoint> Data {
                get {
                    if (data == null)
                        InitCollection();
                    return data;
                }
            }
            static void InitCollection() {
                data = new List<WeatherPoint>();
                int lastYear = DateTime.Now.Year - 1;
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 9), Wind = 5 });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 10), Wind = Double.NaN });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 11), Wind = 5 });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 12), Wind = 5 });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 13), Wind = 6 });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 14), Wind = 3 });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 15) });
                data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 16), Wind = 6 });
            }
            public class WeatherPoint {
                public DateTime Date { get; set; }
                public double? Wind { get; set; }
            }
        }
    }
    

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

You can use the SeriesPoint.IsEmpty property to check whether a point is empty.

Missing points (that is the case when the data source contains missing records in arguments and points are not created) are handled as empty points if the ScaleOptionsBase.ProcessMissingPoints property is set to InsertEmptyPoints.

Tip

Define How to Handle Empty Points

Use a series view’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.

ProcessEmptyPointsMode.Interpolate is enabled

using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace SampleChart {
    public partial class WebForm1 : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            chartControl.DataSource = WeatherDataProvider.Data;
            Series series = new Series("Wind", ViewType.Bar);
            series.SetDataMembers("Date", "Wind");
            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            chartControl.Series.Add(series);
            chartControl.DataBind();

            BarSeriesView view = (BarSeriesView)series.View;
            view.EmptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate;
            view.EmptyPointOptions.Color = Color.FromArgb(80, 80, 80, 80);
        }
    }
    public static class WeatherDataProvider {
        static List<WeatherPoint> data;

        public static List<WeatherPoint> Data {
            get {
                if (data == null)
                    InitCollection();
                return data;
            }
        }
        static void InitCollection() {
            data = new List<WeatherPoint>();
            int lastYear = DateTime.Now.Year - 1;
            data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 11), Wind = 5 });
            data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 12), Wind = 5 });
            data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 13), Wind = 6 });
            data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 14), Wind = 3 });
            data.Add(new WeatherPoint() { Date = new DateTime(lastYear, 7, 15) });
            // ...
            // Other points.
            // ...
        }
        public class WeatherPoint {
            public DateTime Date { get; set; }
            public double? Wind { get; set; }
        }
    }
}

Customize Appearance of Empty Points

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

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

Empty points of different series

LineSeriesView view1 = (LineSeriesView)series1.View;
view1.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True;
LineEmptyPointOptions lineEmptyPointOptions = view1.EmptyPointOptions;
lineEmptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate;
lineEmptyPointOptions.Color = Color.DarkGray;
lineEmptyPointOptions.LineStyle.DashStyle = DashStyle.Dash;
lineEmptyPointOptions.LineStyle.Thickness = 2;

AreaSeriesView view2 = (AreaSeriesView)series2.View;
AreaEmptyPointOptions areaEmptyPointOptions = view2.EmptyPointOptions;
areaEmptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate;
areaEmptyPointOptions.FillStyle.FillMode = FillMode.Solid;
areaEmptyPointOptions.Color = Color.DarkGray;
areaEmptyPointOptions.Border.Color = Color.Gray;
areaEmptyPointOptions.Border.Thickness = 2;

SideBySideBarSeriesView view3 = (SideBySideBarSeriesView)series3.View;
EmptyPointOptions emptyPointOptions = view3.EmptyPointOptions;
emptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate;
emptyPointOptions.Color = Color.FromArgb(100, Color.DarkGray);

Show Isolated Points

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

ShowIsolatedPoints = true ShowIsolatedPoints = false
ShowIsolatedPoints = true ShowIsolatedPoints = false
LineSeriesView view = chart.Series[0].View as LineSeriesView;
view.ShowIsolatedPoints = true;