DataLabel Object


Overview

The DataLabel object can be used to define a label for the data in a group. The label object is an array of text strings that automatically appears in an appropriate context in any view of the group. For example, a label associated with a data series might contain a character string corresponding to each data pair in the series. These strings would appear as row annotation in a table view.

DataLabel objects are created automatically when the user performs a drag-and-drop. If the drag-and-drop begins inside an EditTable object, the column heading becomes the name of the data object, and the row annotation becomes a label array. For instance, if the user selects three columns for drag-and-drop, this will automatically create three DataSampled objects (one for each column), with a DataLabel object containing the annotation for each row.

For a Chart, DataLabel objects are used to annotate the axes. For a Table, DataLabel objects provide row or column annotation. The data label has an orientation which specifies which axis (when attached to a chart) it corresponds to. If you specify more than one DataLabel for a specific orientation, the chart manager will try to merge those labels based on the range information.


Example

The following example shows a typical code structure used to define a DataLabel object.

static String x_labels[] = {"Houston","Dallas","San Antonio", "Austin"};
...
XtVaCreateWidget("Cities", (WidgetClass)xintDataLabelObjectClass, edit,
                 XmNlabelStrings, x_labels,
                 XmNlabelCount, sizeof(x_labels)/sizeof(String),
                 XmNlabelOrientation, XintLABEL_X,
                 XmNdataGroup, data_group, 
                 NULL);


Inherited Resources and Behavior

The DataLabel object class does not inherit behavior and resources from any other object class.
The following resources are defined by the DataLabel object class. These resources must be set as part of the object creation function XintCreateDataLabel discussed later in this section.
NameTypeDefaultAccess
XmNcopyDataBooleanTrueCSG
XmNdataGroupObjectNULLCSG
XmNlabelCountint0CSG
XmNlabelOrientationintXintLABEL_XCSG
XmNlabelPositionArrayfloat *NULLCSG
XmNlabelStringschar **NULLCSG
XmNlastViewDestroyBooleanTrueCSG
XmNsampledRangeXintRange *NULLCSG
XmNupdateCallbackXtCallbackListNULLC


XmNcopyData

If True, this resource will allocate memory to store a copy of the data (label string array and labels), then free the memory when the object is destroyed. If False, the widget does not create a copy of the data or manage memory for this purpose.

XmNdataGroup

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

XmNlabelCount

This is the number of separate character strings contained in this DataLabel object.

XmNlabelOrientation

For a Chart, this resource specifies the axis this label is associated with. For a Table, this resource specifies whether the labels are used for row or column annotation. You can use one of the following constants for the value of this resource:

Resource ValueDescription
XintLABEL_X (default)Label is associated with the X axis (column annotation).
XintLABEL_YLabel is associated with the Y axis (row annotation).
XintLABEL_ZLabel is associated with the Z axis.


XmNlabelPositionArray

This resource specifies an array, of size XmNlabelCount, used to position the labels along a chart axis. This resource should only be used if the increment between the labels is not constant. Use resource XmNsampledRange otherwise.

XmNlabelStrings

This is the text of the label, or the name of a pre-defined array containing a series of character strings to be used as labels.

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.

XmNsampledRange

Specifies the start and increment for positioning the labels. For example, if the label orientation is specified as X, this resource would define the start (position of the first label) and the increment (how far apart are the labels) in the X direction. If this resource is not specified, the start is assumed to be 0 and the increment 1. This resource is helpful to position the annotation on the axis. Use resource XmNlabelPositionArray to position labels at a non constant interval.

This resource is specified as a pointer to a data structure of type XintRange, which takes the following form:

   typedef struct {
                   float start;
                   float increment;
   } XintRange;

where:

MemberDescription
startMinimum value.
incrementIncrement.


XmNupdateCallback

This resource allows you to attach a callback to the Label object that is invoked each time the data has changed. See the following section for more information on this callback.

Callback

Callback XmNupdateCallback provides notification of changes in a DataLabel object. This notification can be used to ensure that updates to one view are properly reflected in all other views. The callback structure takes the following form:

   typedef struct {
                   int        reason;
                   XEvent     *event;
                   Object     object;
   } XintDataLabelUpdateCallbackStruct;

If you have multiple DataLabel or other objects in a group, this callback must be registered separately for each individual data object. If you prefer to control updates at the group level, you should register this callback only once for the DataGroup object and use the XintDataGroupUpdateCallbackStruct discussed earlier in this manual.

The following ordered table describes the members of structure XintDataLabelUpdateCallbackStruct:

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.

Member reason provides information explaining why and how the update occurred. Possible values for member reason are:

ReasonDescription
XintCR_DATA_UPDATE
XintCR_DATA_BATCH
Label has been changed, no more information is available.


Functions

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

Function NameDescription
XintCreateDataLabelCreates a DataLabel object.
XintDataLabelExtendExtends the labels.
XintDataLabelReplaceReplaces the labels.
XintDataLabelShiftShifts the labels.


XintCreateDataLabel

This function is used to create a data label and define all resources for it.

     Object XintCreateDataLabel (...)

WidgetparentParent of the new data label.
char *nameName of new data label object.
ArgListarglistList of resource settings for the new object.
Cardinalargcount Number of resources being set in arglist.


XintDataLabelExtend

This function adds more labels to the end of a data label array. The function returns False if there is a bad argument, if the function cannot be performed, or if resource XmNcopyData is false.

     Boolean XintDataLabelExtend (...)

ObjectobjectObject ID of the label array to be extended.
String *string_arrayArray of strings to be added to the original label array.
float *pos_arrayArray of positions to be added to the original position array (Specify NULL if you are not using this field).
intcountNumber of values being added.


XintDataLabelReplace

This function replaces a range of labels in the label array. The function returns False if there is a bad argument.

     Boolean XintDataLabelReplace(...)

ObjectobjectObject ID of the label array to be replaced.
String *string_arrayArray of new strings to be used to replace existing labels.
float *pos_arrayArray of positions to be used to replace existing positions (Specify NULL if you are not using this field).
intstartIndex of first value to be replaced (starts at 0).
intcountNumber of values being replaced.


XintDataLabelShift

This function shifts the labels contained in a DataLabel object by discarding a specified number of values at the beginning of the existing array, and adding an equal number of values to the end of the existing array.. The function returns False if argument count is bigger than the number of labels.

     Boolean XintDataLabelShift(...)

ObjectobjectObject ID of the label array to be shifted.
String *string_arrayArray of new strings to be appended at the end of the list of labels.
float *pos_array Array of positions to be used to be appended at the end of the position list (Specify NULL if you are not using this field).
intcountNumber of values to be discarded at the front and appended to the end of the existing array.


Macros

Macro XintIsDataLabel returns True if the specified object is a DataLabel object.

     Boolean XintIsDataLabel (Object object)