Jump to content
Software FX Community

Adding Points using API with DateTime Axis and DBNull values


User (Legacy)

Recommended Posts

Hi,

I am using ChartFX for VS .NET 2005 to plot multiple series against a

DateTime axis.

I have been using an ADO .NET DataTable successfully to plot a single series

of GalleryType=Step based on a column with no DBNull values, and now I need

to display multiple series, each of which has many DBNull values.

I can't seem to get even 1 series of data with some DBNull values to plot

against a DateTime axis when the data has null values, when I use data

binding instead of the ChartFX API to add 1 point at a time.

Questions:

1. How can I add a point to a ChartFX chart using the API when the X-Axis is

a DateTime axis?

chart1.Data[seriesNumber, pointNumber] seems to make no reference to a

DateTime X-Axis.

2. What's the best way to plot 3 or 4 series from an ADO .NET datatable

whose columns have some DBNull values?

If I use DataBinding, what is the easiest way to hide the DBNull points? Is

it better in this case to loop through the points and add them one at a time

using the API?

3. What else should I know about trying to plot DBNull values, esp. against

a DateTime X-Axis, using ChartFX for VS .NET 2005?

Thank you very much,

Brook Hunter

Link to comment
Share on other sites

> 1. How can I add a point to a ChartFX chart using the API when the X-Axis 

> is a DateTime axis?

First of all, it is important to distinguish between two possible uses for

the date (x-axis) values:

a) If the chart type is a line chart or any other type that supports X/Y

coordinates, the X-Axis is independent of the data itself and the points are

plotted at their position according to the X-Value. This allows for multiple

series having different date x-values.

B) If the chart type does not support X-Values, such as Bar, the dates are

used as "data-driven labels", this means the dates do not affect the

position of the bars but they only affect the labeling of the X-Axis, in

this case, only the first series´ X-Values (or shared X-Values) are used,

therefore you can not combine two series with different sets of x-values.

If there is only one date column in your dataset, both scenarios can be

achieved (shared X-Values).

To assign X-Values using the API you can use:

chart.Data.X[i,j]

> 2. What´s the best way to plot 3 or 4 series from an ADO .NET datatable

> whose columns have some DBNull values?

This depends on how do you want to interpret null values. By default Null

values are translated into "hidden" points, which means that the space

allotted for this point will be left blank, in a connected chart type, such

as line, this will generate a break in the line (you can bypass this break

by using DataValues.InterpolateHidden, see docs for details). Your data

would look like this:

Date Series1 Series2

1/1/2001 30 40

1/3/2001 20

1/4/2001 45

1/5/2001 70

1/6/2001 50 60

If you are doing a Line chart (or a chart supporting X-Values) you may

decide to strip these null values from your dataset so that Chart FX only

receives the actual values (no nulls), since the dates dictate the position

of each point, you will need a separate set of dates for each series, your

data will end up looking like this (for the same data):

Date1 Series1 Date2 Series2

1/1/2001 30 1/1/2001 40

1/3/2001 20 1/4/2001 45

1/6/2001 50 1/5/2001 70

null null 1/6/2001 60

Notice that using this approach, all null values (if any) end up at the end

of the dataset.

> 3. What else should I know about trying to plot DBNull values, esp.

> against a DateTime X-Axis, using ChartFX for VS .NET 2005?

The information above should cover this one.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...