aspnet-15959-components-chart-control-concepts-creating-charts-data-representation-empty-points.md
Empty points are points with undefined Values. This document describes how the Chart Control processes 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.
Set a data point’s value to Double.NaN or leave it unspecified in a data source.
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
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.
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; }
}
}
}
Imports DevExpress.XtraCharts
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Namespace SampleChart
Public Partial Class WebForm1
Inherits Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
chartControl.DataSource = Data
Dim series As Series = New Series("Wind", ViewType.Bar)
series.SetDataMembers("Date", "Wind")
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.[True]
chartControl.Series.Add(series)
chartControl.DataBind()
Dim view As BarSeriesView = CType(series.View, BarSeriesView)
view.EmptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate
view.EmptyPointOptions.Color = Color.FromArgb(80, 80, 80, 80)
End Sub
End Class
Public Module WeatherDataProvider
Private dataField As List(Of WeatherPoint)
Public ReadOnly Property Data As List(Of WeatherPoint)
Get
If dataField Is Nothing Then Call InitCollection()
Return dataField
End Get
End Property
Private Sub InitCollection()
dataField = New List(Of WeatherPoint)()
Dim lastYear As Integer = Date.Now.Year - 1
Call dataField.Add(New WeatherPoint() With {
.[Date] = New DateTime(lastYear, 7, 11),
.Wind = 5
})
Call dataField.Add(New WeatherPoint() With {
.[Date] = New DateTime(lastYear, 7, 12),
.Wind = 5
})
Call dataField.Add(New WeatherPoint() With {
.[Date] = New DateTime(lastYear, 7, 13),
.Wind = 6
})
Call dataField.Add(New WeatherPoint() With {
.[Date] = New DateTime(lastYear, 7, 14),
.Wind = 3
})
Call dataField.Add(New WeatherPoint() With {
.[Date] = New DateTime(lastYear, 7, 15)
})
' ...
' Other points.
' ...
End Sub
Public Class WeatherPoint
Public Property [Date] As Date
Public Property Wind As Double?
End Class
End Module
End Namespace
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:
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);
Dim view1 As LineSeriesView = CType(series1.View, LineSeriesView)
view1.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True
Dim lineEmptyPointOptions As LineEmptyPointOptions = view1.EmptyPointOptions
lineEmptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate
lineEmptyPointOptions.Color = Color.DarkGray
lineEmptyPointOptions.LineStyle.DashStyle = DashStyle.Dash
lineEmptyPointOptions.LineStyle.Thickness = 2
Dim view2 As AreaSeriesView = CType(series2.View, AreaSeriesView)
Dim areaEmptyPointOptions As 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
Dim view3 As SideBySideBarSeriesView = CType(series3.View, SideBySideBarSeriesView)
Dim emptyPointOptions As EmptyPointOptions = view3.EmptyPointOptions
emptyPointOptions.ProcessPoints = ProcessEmptyPointsMode.Interpolate
emptyPointOptions.Color = Color.FromArgb(100, Color.DarkGray)
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 |
|---|---|
LineSeriesView view = chart.Series[0].View as LineSeriesView;
view.ShowIsolatedPoints = true;
Dim view As LineSeriesView = TryCast(chart.Series(0).View, LineSeriesView)
view.ShowIsolatedPoints = True