AddData

Adds a value to the end of a series of a graph. The syntax you use depends on the type of graph.

To add data to

Use

Any graph type except scatter

Syntax 1 For all graph types except scatter

Scatter graphs

Syntax 2 For scatter graphs


Syntax 1 For all graph types except scatter

Description

Adds a data point to a series in a graph. Use Syntax 1 for any graph type except scatter graphs.

Applies to

Graph controls in windows and user objects. Does not apply to graphs within DataWindow objects because their data comes directly from the DataWindow.

Syntax

controlname.AddData ( seriesnumber, datavalue {, categoryvalue } )

Argument

Description

controlname

The name of the graph in which you want to add data to a series. The graph’s type should not be scatter.

seriesnumber

The number that identifies the series to which you want to add data.

datavalue

The value of the data you want to add.

categoryvalue (optional)

The category for this data value on the category axis. The datatype of the categoryvalue should match the datatype of the category axis. In most cases you should include categoryvalue. Otherwise, an uncategorized value will be added to the series.

Returns

Long. Returns the position of the data value in the series if it succeeds and -1 if an error occurs. If any argument’s value is null, AddData returns null.

Usage

When you use Syntax 1, AddData adds a value to the end of the specified series or to the specified category, if it already exists. If categoryvalue is a new category, the category is added to the end of the series with a label for the data point’s tick mark. If the axis is sorted, the new category is incorporated into the existing order. If the category already exists, the new data replaces the old data at the data point for the category.

For example, if the third category label specified in series 1 is March and you add data in series 4 and specify the category label March, the data is added at data point 3 in series 4.

When the axis datatype is string, you can specify the empty string ("") as the category name. Because category names must be unique, there can be only one category with a blank name. If you use AddData to add data without specifying a category, you will have data points without categories, which is not the same as a category whose name is "".

To insert data in the middle of a series, use InsertData. You can also use InsertData to add data to the end of a series, as AddData does, although it requires an additional argument to do it.

For a comparison of AddData, InsertData, and ModifyData, see Equivalent Syntax in InsertData.

Examples

Example 1

These statements add a data value of 1250 to the series named Costs and assign the data point the category label Jan in the graph gr_product_data:

integer SeriesNbr


// Get the number of the series.

SeriesNbr = gr_product_data.FindSeries("Costs")

gr_product_data.AddData(SeriesNbr, 1250, "Jan")

Example 2

These statements add a data value of 1250 to the end of the series named Costs in the graph gr_product_data but do not assign the data point to a category:

integer SeriesNbr


// Get the number of the series.

SeriesNbr = gr_product_data.FindSeries("Costs")

gr_product_data.AddData(SeriesNbr, 1250)

See also


Syntax 2 For scatter graphs

Description

Adds a data point to a series in a scatter graph.

Syntax

controlname.AddData ( seriesnumber, xvalue, yvalue )

Argument

Description

controlname

The name of the scatter graph in which you want to add data to a series. The graph’s type should be scatter.

seriesnumber

The number that identifies the series to which you want to add data.

xvalue

The x value of the data point you want to add.

yvalue

The y value of the data point you want to add.

Returns

Long. Returns the position of the data value in the series if it succeeds and -1 if an error occurs. If any argument’s value is null, AddData returns null.

Examples

Example 3

These statements add the x and y values of a data point to the series named Costs in the scatter graph gr_sales_yr:

integer SeriesNbr


// Get the number of the series.

SeriesNbr = gr_sales_yr.FindSeries("Costs")

gr_sales_yr.AddData(SeriesNbr, 12, 3)

See also