Dundas Chart for Windows Forms
Empty Data
See Also Send comments on this topic.
Working with Data > Empty Data



Glossary Item Box

Overview

Empty data points are points that do not have Y values. These data points are useful for controlling the appearance and structure of your chart's data, as well as handling points whose data is a null value.

 

Empty points can be used for:

 

An Example Using Empty Points

The following chart displays a daily sales report for one week. From the chart shown in Figure 1 below, no sales are recorded or shown for Wednesday. Is this because the amount of sales on Wednesday was zero, or was it because of a holiday business closure for this day? If there were no sales recorded at all, and no explanation is offered as to why this is the case, then this is missing data.

 

Figure 1: Ambiguity over possible missing data on Wednesday.

 

Missing data can be represented as an empty point in the same way that empty points are used to represent nulls in a database field. Here is the same chart with an empty point used for Wednesday's data. As you can see in Figure 2, the ambiguity is removed by including the empty point in the chart's legend. Now we know that Wednesday was a holiday, and as such we should expect that no sales took place on that day.

 


Figure 2: No data due to a holiday.

 

Appearance of Empty Points

You can change the visual representation of plotted empty points by using the EmptyPointStyle property of the series that the point belongs to. Different attributes may be used, and depend only on the ChartType property of the series. The EmptyPointValue custom attribute can be used to treat empty points as zeros, or as an average of the points to the left and right of them.

For more information, refer to the topic on Custom Attributes.

   
Example 

This example demonstrates how to set different empty point attributes for a three line chart series. The first series makes use of a marker to represent the empty point, the second series treats the empty point as an average, and the third series treats the empty point as a value of zero. We assume that 3 series named "Series1", "Series2" and "Series3" were added to the control at design-time, along with 10 data points per series. We also assume that the third point was missing, and has been marked as Empty. Information on adding an empty point immediately follows this sample. Finally, we assume that the DundasBlue template has been applied to the original chart for appearance purposes.

 


Figure 3: Different empty point styles.

 

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
  ...

' Show marker (red cross) instead of a line for first series.
chart1.Series("Series1").EmptyPointStyle.BorderWidth = 1
chart1.Series("Series1").EmptyPointStyle.BorderColor = Color.Black
chart1.Series("Series1").EmptyPointStyle.MarkerColor = Color.Red
chart1.Series("Series1").EmptyPointStyle.MarkerSize = 15
chart1.Series("Series1").EmptyPointStyle.MarkerStyle = MarkerStyle.Cross
 
' Show empty point of second series as thin dotted line (treated as an average).
chart1.Series("Series2").EmptyPointStyle.BorderStyle = ChartDashStyle.DashDotDot
chart1.Series("Series2").EmptyPointStyle.MarkerColor = Color.FromArgb(64, 64, 64)
 
' Treat empty point of third series as a zero using the EmptyPointValue custom attribute.
chart1.Series("Series3").EmptyPointStyle.BorderWidth = 1
chart1.Series("Series3").EmptyPointStyle.MarkerColor = Color.FromArgb(0, 192, 0)
chart1.Series("Series3").EmptyPointStyle.CustomAttributes = "EmptyPointValue = Zero"

C# Copy Code
using Dundas.Charting.WinControl;
  ...
  
// Show marker (red cross) instead of a line for first series.
chart1.Series["Series1"].EmptyPointStyle.BorderWidth = 1;
chart1.Series["Series1"].EmptyPointStyle.BorderColor = Color.Black;
chart1.Series["Series1"].EmptyPointStyle.MarkerColor = Color.Red;
chart1.Series["Series1"].EmptyPointStyle.MarkerSize = 15;
chart1.Series["Series1"].EmptyPointStyle.MarkerStyle = MarkerStyle.Cross;

// Show empty point of second series as thin dotted line (treated as an average).
chart1.Series["Series2"].EmptyPointStyle.BorderStyle = ChartDashStyle.DashDotDot;
chart1.Series["Series2"].EmptyPointStyle.MarkerColor = Color.FromArgb(64, 64, 64);

// Treat empty point of third series as a zero using the EmptyPointValue custom attribute.
chart1.Series["Series3"].EmptyPointStyle.BorderWidth = 1;
chart1.Series["Series3"].EmptyPointStyle.MarkerColor = Color.FromArgb(0, 192, 0);
chart1.Series["Series3"].EmptyPointStyle.CustomAttributes = "EmptyPointValue = Zero";

 

Adding Empty Points

Empty data points can be added to a series using any of the following techniques.

To add an empty point to a data series, you can:


Using the InsertEmptyPoints Method

This function uses intervals along the x-axis to check if a data point exists for each of the intervals. If no point exists, an empty point is inserted.

 

Here are the parameters for the InsertEmptyPoints method:

 

Note
If an output series is specified by name, and a series by the same name does not exist in the chart's Series collection, then a new series will be created and added to the collection. The new series will have all of it attributes set to their default values.

 

 

Empty points can be simultaneously inserted into multiple series by specifying the names of those series in a comma separated list.

 

Caution
If a list of output series are specified, then the number of output series must equal the number of input series, or an exception will be thrown.

 

 

All series of the chart Series collection may be grouped together if "*" is specified as the input series name (in which case no output series should be specified).

Example

This example demonstrates how to insert empty points into two series. In "Series1" we check each day, and insert an empty point if a day does not have data. The input series is used to store the resulting data. In the second function call, we only check for missing data every Monday by using an offset, and unlike the first method call, we store the resulting data in a series other than the input series, thereby preserving the original series' data.

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
  ...
  
With Chart1.DataManipulator
' Insert empty point for each day if there is no data point present.
.InsertEmptyPoints(1, IntervalType.Days, "Series1")
' Insert empty point for each Monday, but if there is no data point present, then
' Monday is offset by 1 day from the beginning of the week (Sunday).
.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series2", "ResultSeries")

C# Copy Code
using Dundas.Charting.WinControl;
  ...
  
DataManipulator myManip = Chart1.DataManipulator;
// Insert empty point for each day if there is no data point present.
myManip.InsertEmptyPoints(1, IntervalType.Days, "Series1");
// Insert empty point for each Monday, but if there is no data point present, then
// Monday is offset by 1 day from the beginning of the week (Sunday).
myManip.InsertEmptyPoints(1, IntervalType.Weeks, 1, IntervalType.Days, "Series2", "ResultSeries");

See Also

©2009. All Rights Reserved.