In the example that follows, we will show you how to create a combo plot which contains two plots. The bar plot is placing its x_axis at the bottom of the combo plot and its y_axis at the left, while the line plot is placing its x_axis at the top and its y_axis at the right.
Object chart;
:
:
XintChartSaveTemplate("template_file", &chart, 1);
:
Because only the visual attributes are saved, you can associate the
chart with new data when it is restored in another application. Another
function,
XintChartReadTemplate() , reads the chart objects stored in a template
file created by XintChartSaveTemplate().
The first method is to find the widget ID of the object for which you want to disable the editing -- either you already have it, or you can get it with the INT convenience function XintChartGetComponent(refer to Question No. 5). Then set the resource XmNsensitive to False. There is, however, one problem with this method. When you set the resource XmNsensitive to False, the object can no longer be selected, so it can not be moved or resized by the end user.
The following code fragment shows how to disable the editing of the legend of the chart.
:
:
legend = XintChartGetComponent(chart, XintCHART_COMPONENT_LEGEND);
XtVaSetValues((Widget)legend, XmNsensitive, False, NULL);
:
:
The second method is to disable the resource dialogs by registering callback XmNresourceDialogCallback
on the EditObject Widget and setting the doit flag member of the callback structure to False. In the
following example, the editing of the legend is disabled, yet the legend can be selected and moved!
The following code fragment shows how to get the limits with the functin XtVaGetValues().
:
Object chart, plot;
XintLimits y_limits;
:
:
plot = XintChartGetComponent(chart, XintCHART_COMPONENT_PLOT);
XtVaGetValues((Widget)plot, XmNyLimits, &y_limits, NULL);
:
In the following example, we will show you how to 1) Remove XmNchartFooter and XmNshowLegend editors from the chart resource editor menu; 2) Change name of option menu "Chart Type" to "My Type"; and 3) Disable High Low and Cell Array choices in chart type.
In the following example, we will show you how to build your own legend object editor, which allows only title editing.
To unzoom the chart (i.e. to zoomout to the full viewport), you need only to set both XmNxLimits and XmNyLimits to NULL.
In the following example, when you hold down button 1 to select an area, the viewport is zoomed to the area you select. To unzoom it, just hold down the Control key and click button 1.
Each object class defines a specific resource or set of resources that describe the geometry of the object. The coordinate system used to describe the object geometry is normally the one defined by its parent. In graphic object class, two resources, XmNhorizontalAxis and XmNverticalAxis, can be used to specify a diferent coordinate system vertically, horizontally or both. So, suppose you are placing a graphic object into a chart. If the object is inserted inside the chart, its coordinate system is the Chart coordinate system which is between 0 and 100 in both the horizontal and vertical directions. If the object is inserted inside a Plot2D, its coordinate system is the one defined by the axes (if there are any) attached to the Plot2D object.
In the following example, we will first get the cursor position, which is in the pixel value, via Locator action, then transform it into EditObject Coordinate system. Please note that the EditObject coordinate is already available in the callback structure. We did not use it simply because we were showing you how to do transformations between the two coordinate systems.
In the following example, we will specify that the line associated with the DataSeries can only move horizontally. The label strings and positions of the X axis will be changing accordingly.
After you create the symbol, you can modify it with the built-in symbol editor. The symbol editor is invoked by double clicking on the symbol.
Now, if you want to keep any component in a chart from being moved, you can do it this way:
:
static void NonMoveCallback(widget, data, cb)
Widget widget;
XtPointer data;
XintChartVerifyCallbackStruct *cb;
{
if (cb->reason == XintCR_OBJECT_MOVE)
cb->doit = False;
}
/* in main() */
:
:
XtAddCallback((Widget)chart, XmNverifyCallback,
(XtCallbackProc) NonMoveCallback, NULL);
:
:
In the program, if you have data arrays like this,
static float d1992[] = { 05.0, 30.0, 20.0, 20.0};
static float d1993[] = { 10.0, 45.0, 32.0, 30.0};
static float d1994[] = { XintUNDEFINED_FLOAT, 25.0, 27.0, 35.0};
you will end up with a chart like this.