DataSeries Object Class


Overview

The DataSeries object class is used to store, retrieve, and manipulate any series of (x,y) data pairs. Each data group may contain multiple DataSeries objects (for instance, multiple columns from a table or multiple lines on a chart). The series is specified as an array of X data points, with a matching array of Y data points. Compared to the DataSampled object, the DataSeries object is more suitable for describing random series of irregularly spaced data points. The type of data contained in a DataSeries Object can be float, short, integer, long, or double.

Example

The following example shows the code structure for a typical DataSeries object.

   static float x_coord[] = {12.4, 23.5, 28.1, 31.5};
   static float y_coord[] = {123, 432, 234, 121};
   Object point_series;
   ...
   point_series = (Object) XtVaCreateWidget("series",
                               (WidgetClass)xintDataSeriesObjectClass, edit,
                               XmNxArray, x_coord,
                               XmNyArray, y_coord,
                               XmNcount, sizeof(x_coord)/sizeof(float),
                               XmNdataType, XintDATA_TYPE_FLOAT,
                               XmNcopyData, False,
                               NULL);


Inherited Resources and Behavior

The DataSeries object class does not inherit behavior and resources from any other object class.
The following resources are defined by the DataSeries object class:
NameTypeDefaultAccess
XmNcopyDataBooleanTrueCSG
XmNcountint0CSG
XmNdataGroupObjectNULLCSG
XmNdataTypeintXintDATA_TYPE_FLOATCSG
XmNeditableBooleanFalseCSG
XmNlastViewDestroyBooleanTrueCSG
XmNupdateCallbackXtCallbackListNULLCSG
XmNxArrayXtPointerNULLCSG
XmNyArrayXtPointerNULLCSG


XmNcopyData

If True, this resource will allocate memory to store a copy of the data, then free the memory allocation when the object is destroyed. If False, the widget does not create a copy of the data or manage memory for this purpose.

XmNcount

Specifies the number of data values in the X and Y data arrays that were specified by XmNxArray and XmNyArray.

XmNdataGroup

Specifies the object ID of the data group to which this object belongs. This resource must be specified if the data series object is to be placed inside a group.

XmNdataType

Specifies the data type for the resources XmNxArray and XmNyArray. You can specify one of the following constants for the value of this resource:

Resource ValueDescription
XintDATA_TYPE_FLOATData type is float (default).
XintDATA_TYPE_SHORTData type is short.
XintDATA_TYPE_INTEGERData type is integer.
XintDATA_TYPE_LONGData type is long.
XintDATA_TYPE_DOUBLEData type is double.


XmNeditable

Specifies whether or not this data series can be edited when displayed in a view.

XmNlastViewDestroy

Specifies whether or not to automatically destroy this data object when there are no more views connected to the data. If this data object is inserted into a DataGroup, you only need to set this resource for the DataGroup object.

XmNupdateCallback

This resource allows you to attach a callback to the object, as described in the following section.

XmNxArray, XmNyArray

Specifies the names of the pre-defined X and Y data arrays containing the data in this series. The array size is expressed through the resource XmNcount and the data type is specified by XmNdataType, discussed later in this section. The default value of this resource is NULL.

Callbacks

The callback XmNupdateCallback can be used to provide notification of changes in a DataSeries object. Similarly as for widgets, you can register this callback with the Xt function XtAddCallback. When connected to a view (Chart or Table for example), this notification is used to ensure that updates to one view are properly reflected in all other applicable views.

The callback structure takes the following form:

   typedef struct {
                   int    reason;
                   XEvent *event;
                   Object object;
                   int    x_start;
                   int    x_count;
                   int    y_start;
                   int    y_count;
  } XintDataSeriesUpdateCallbackStruct;

When used with DataSeries objects, this callback must be registered individually for each object. If you prefer to control updates at the group level, you should register the callback at the group level and use XintDataGroupUpdateCallbackStruct discussed earlier in this manual.

The callback provides information indicating why and how the object was modified. The following ordered table describes the members of XintDataSeriesUpdateCallbackStruct:

Data TypeMemberDescription
intreasonIndicates why callback was invoked (see table below).
XEvent *eventStandard member in Motif callback structure; not used in this context (will always be NULL).
ObjectobjectID of the updated object.
intx_startStarting index of X values updated (starts at 0).
intx_countTotal number of X values updated.
inty_startStarting index of Y values updated (starts at 0).
inty_countTotal number of Y values updated.

The callback structure includes information explaining the reason why a particular update occurred. The reasons below are contained in the header file Data.h.

ReasonDescription
XintCR_DATA_UPDATE
XintCR_DATA_BATCH
Entire X and Y arrays have been changed, no more information is available.
XintCR_DATA_REPLACEData was replaced in the object, as specified by members x_start, x_count, y_start and y_count;
XintCR_DATA_EXTENDData was added to the object (x_count values where added).
XintCR_DATA_SHIFTData was shifted in the object (x_count values where shifted).


Defined Functions

The following functions are defined for creating and manipulating DataSeries objects.

Function NameDescription
XintCreateDataSeriesCreates a DataSeries object.
XintDataSeriesDataExtendAdds extra data points to a data series.
XintDataSeriesDataReplaceReplaces a specified range of values in a data series.
XintDataSeriesDataShiftShifts the data in a data series to a new range of values.
XintDataSeriesGetXArrayReturns part of the X array and converts it to a float value.
XintDataSeriesGetYArrayReturns part of the Y array and converts it to a float value.


XintCreateDataSeries

This function creates a data series object and defines all the resources for it.

     Object XintCreateDataSeries (...)

WidgetparentParent of new data series object.
char *nameName of new data series object.
ArgListarglistList of resource settings for the new data object.
CardinalargcountNumber of resources set by arglist.


XintDataSeriesDataExtend

This function adds additional data to the end of a series array. The values to be added must be defined in separate X and Y arrays. Both arrays must contain an equal number of values representing matched (x,y) pairs. The function returns False if there is a bad argument or resource XmNcopyData is False.

     Boolean XintDataSeriesDataExtend (...)

ObjectobjectObject ID of the data series array to be extended.
XtPointerx_arrayArray of X values to be added to the data series. The data type for this array should be the same as the type specified by XmNdataType.
XtPointery_arrayArray of matching Y values to be added to the data series. The data type for this array should be the same as the type specified by XmNdataType.
intcountNumber of (x,y) pairs being added.


XintDataSeriesDataReplace

This function replaces the range of values specified. The function returns False if there is a bad argument or if the function cannot be performed.

     Boolean XintDataSeriesDataReplace (...)

ObjectobjectID of the data series object in which data is being replaced.
XtPointerx_arrayArray containing X replacement values. The data type for this array should be the same as the type specified by XmNdataType.
XtPointery_arrayArray containing Y replacement values. The data type for this array should be the same as the type specified by XmNdataType.
intstartIndex of first value to be replaced in the existing array.
intcountTotal number of (x,y) pairs being replaced.


XintDataSeriesDataShift

This function shifts the data contained in a DataSeries object by discarding a specified number of values at the beginning of the existing arrays, and adding an equal number of values to the end of the existing arrays. For example, you may want to discard the first four points in a data series and add four new points to the end of the data series.

The values to be added must be defined in separate X and Y arrays. Both arrays must contain an equal number of values representing matched (x,y) pairs, and the total number of values in the new arrays must equal the number of values to be discarded from the existing arrays. The function returns False if argument count is incorrect.

     Boolean XintDataSeriesDataShift (...)

ObjectobjectID of the data series array.
XtPointerx_arrayArray of X values to be appended to the end of the current X array in the DataSeries object. The data type for this array should be the same as the type specified by XmNdataType.
XtPointery_arrayArray of Y values to be appended to the end of the current Y array in the DataSeries object. The data type for this array should be the same as the type specified by XmNdataType.
intcountNumber of values to be discarded at the front and appended to the end of the existing array.


XintDataSeriesGetXArray, XintDataSeriesGetYArray

This function retrieves any part of the X or Y array in an existing DataSeries object and returns it as an array of float values. If the data is not already classified as float, it converts the data type to float. You will need to free the returned array after it is no longer needed.

     float *XintDataSeriesGetXArray (...)

     float *XintDataSeriesGetYArray (...)

ObjectobjectID of the DataSeries object containing the desired data.
intstartIndex of first value to be retrieved.
intcountNumber of values to be retrieved.


Macros

Macro XintIsDataSeries returns True if the specified object is a DataSeries object.

     Boolean XintIsDataSeries (Object object)