class CwGraph PtBasic { graph_flags; // flag graph_traces; // long graph_x_axis_color; // color graph_x_axis_width; // integer graph_x_font; // string graph_x_label; // string graph_x_label_color; // color graph_x_major_length; // integer graph_x_major_tick; // double array graph_x_minor_length; // integer graph_x_minor_tick; // double array graph_xmax; // double array graph_xmin; // double array graph_y_axis_color_left; // color graph_y_axis_color_right; // color graph_y_axis_width_left; // integer graph_y_axis_width_right; // integer graph_y_font_left; // string graph_y_font_right; // string graph_y_label_color_left; // color graph_y_label_color_right; // color graph_y_label_left; // string graph_y_label_right; // string graph_y_major_length_left; // integer graph_y_major_length_right; // integer graph_y_major_tick_left; // double array graph_y_major_tick_right; // double array graph_y_minor_length_left; // integer graph_y_minor_length_right; // integer graph_y_minor_tick_left; // double array graph_y_minor_tick_right; // double array graph_ymax_left; // double array graph_ymax_right; // double array graph_ymin_left; // double array graph_ymin_right; // double array }
This widget is a graph that allows plotting multiple curves of arbitrary length, with options for one x-axis display, and two independent y-axis displays (left and right). It uses floating-point numbers in any scale, with independent scaling for each curve.
![]() | This widget does not appear in the Photon documentation. |
This instance variable may be a combination of zero or more of the following flags. Most of these flags correspond to instance variables in the widget. Unsetting a flag here overrides the assignment of any corresponding instance variables.
| Constant | Description |
|---|---|
| Cw_GRAPH_X_AXIS | Show the x-axis on the graph. Default is set. |
| Cw_GRAPH_X_AXIS_DATE | Not currently implemented. |
| Cw_GRAPH_X_AXIS_LABEL | Show numbers on the x-axis. Default is set. |
| Cw_GRAPH_X_MAJOR_TICK | Show major tick marks on the x-axis. Default is set. Unsetting this variable will make the major tick marks appear as minor tick marks if Cw_GRAPH_X_MINOR_TICK is set, otherwise the major tick marks will not appear at all. |
| Cw_GRAPH_X_MINOR_TICK | Show minor tick marks on the x-axis. Default is set. |
| Cw_GRAPH_X_AXIS_TIME | Show the graph_major_ticks on the x-axis label as times. Default is not set. |
| Cw_GRAPH_X_AXIS_TITLE | Show the graph_x_label string on the x-axis label. Default is set. |
| Cw_GRAPH_Y_AXIS_LEFT, Cw_GRAPH_Y_AXIS_RIGHT | Show the left or right y-axis on the graph. Default is set. |
| Cw_GRAPH_Y_AXIS_LABEL_LEFT, Cw_GRAPH_Y_AXIS_LABEL_RIGHT | Show numbers on the left or right y-axis. Default is set. |
| Cw_GRAPH_Y_MAJOR_TICK_LEFT, Cw_GRAPH_Y_MAJOR_TICK_RIGHT | Show major tick marks on the left or right y-axis. Default is set. Unsetting this variable will make the major tick marks appear as minor tick marks if either of the Cw_GRAPH_Y_MINOR_TICK flags are set, otherwise the major tick marks will not appear at all. |
| Cw_GRAPH_Y_MINOR_TICK_LEFT, Cw_GRAPH_Y_MINOR_TICK_RIGHT | Show minor tick marks on the left or right y-axis. Default is set. |
| Cw_GRAPH_Y_AXIS_TITLE_LEFT, Cw_GRAPH_Y_AXIS_TITLE_RIGHT | Show the graph_x_label string on the left or right y-axis label. Default is set. |
A positive integer specifying how many traces the widget will use. The traces are identified by consecutive integers starting with 0.
A number specifying the color of the x-axis. Default is 0x0 (black).
An integer specifying the width in pixels of the x-axis line. Default is 1.
A string specifying the font for the x-axis display. Default is "helv12".
A string specifying the label to use for the x-axis. Default is "X".
A number specifying the color to use for the x-axis line. Default is 0x0 (black).
An integer specifying the length of the major tick marks of the x-axis, in pixels. Default is 5.
A number specifying the interval of the major tick marks on the x-axis.
An integer specifying the length of the minor tick marks of the x-axis, in pixels. Default is 2.
A number specifying the interval of the minor tick marks on the x-axis.
A number specifying the maximum value on the x-axis. This number determines the upper limit of x values to be displayed.
A number specifying the minimum value on the x-axis. This number determines the lower limit of x values to be displayed.
A number specifying the color of the left or right y-axis. Default is 0x0 (black).
An integer specifying the width in pixels of the left or right y-axis line. Default is 1.
A string specifying the font for the left or right y-axis display. Default is "helv12".
A number specifying the color to use for the left or right y-axis line. Default is 0x0 (black).
A string specifying the label to use for the left or right y-axis. Default is "Y".
An integer specifying the length of the major tick marks of the left or right y-axis, in pixels. Default is 5.
A number specifying the interval of the major tick marks on the left or right y-axis.
An integer specifying the length of the minor tick marks of the left or right y-axis, in pixels. Default is 2.
A number specifying the interval of the minor tick marks on the left or right y-axis.
A number specifying the maximum value on the left or right y-axis. This number does not determine the upper limit of y values to be displayed. That value is determined by the CwGraphSetYLimits function.
A number specifying the minimum value on the left or right y-axis. This number does not determine the lower limit of y values to be displayed. That value is determined by the CwGraphSetYLimits function.
These arguments are used in the functions listed below.
| buffer | A buffer containing pairs of doubles in binary form, used by CwGraphAddRawPoints. |
| color | A number specifying a color. |
| count | The number of pairs to read, used by CwGraphAddRawPoints. |
| npoints | A number of points. |
| onoff | An integer: 0 or nil = disable, all other values = enable. Used by CwGraphEnableTrace. |
| pointno | The number of the point in the trace. Points are numbered by consecutive integers, starting at 0. |
| points | A number specifying the number of points desired. |
| start | The starting point for reading the buffer, used by CwGraphAddRawPoints. |
| trace | The trace number. |
| widget | A CwGraph widget. |
| x | A list of the x coordinates of the trace. |
| y | A list of the y coordinates of the trace |
| ymax | A number specifying the upper limit of y values to be displayed. |
| ymin | A number specifying the lower limit of y values to be displayed. |
CwGraphAddRawPoints (widget, trace, buffer, start, count) -- adds points as pairs of double-precision 8-bit numbers.
Returns t on success, else error.
CwGraphAddXYPoints (widget, trace, x, y) -- adds multiple points, using lists of x and y coordinates.
Returns t on success, else error.
Returns t on success, else error.
Returns t on success, else error.
CwGraphGetScreenData (widget, trace, pointno, npoints) -- gets screen data about specified points in the trace, expressed as a pointer to a binary file.
Returns a pointer to a binary file, or error.
CwGraphGetTraceData (widget, trace, pointno, npoints) -- gets data about specified points in the trace, expressed as a pointer to a binary file.
Returns a pointer to a binary file.
Returns t on success, else error.
Returns t on success, else error.
CwGraphSetYLimits (widget, trace, ymin, ymax) -- sets the upper and lower y-axis limits for the display of traces. These limits are independent of the graph_ymin and graph_ymax instance variable values for the widget.
Returns t on success, else error.
This example, ex_CwGraph.g, is included in the gamma_ph_#_examples_1_QNX4.tgz file available on the Cogent Web Site.
#!/usr/cogent/bin/phgamma
/*
* This example demonstrates a CwGraph.
*/
/*
* Load the required files, which include two dynamic
* libraries that are not generally needed for Photon
* widgets.
*/
if (_os_ == "QNX4")
{
dyna_add_lib("/usr/cogent/lib/photon_s.dlb");
dyna_add_lib("/usr/cogent/lib/phwidgets.dlb");
}
require_lisp("PhotonWidgets.lsp");
PtInit(nil);
win = new(PtWindow);
grf = new(CwGraph);
grf.SetDim(400,300);
grf.fill_color = 0xffeeaa;
/*
* Define the x_axis display.
*/
grf.graph_traces = 3;
grf.graph_x_axis_color = 0x00aaff;
grf.graph_x_axis_width = 2;
grf.graph_x_font = "lu10";
grf.graph_x_label = "X Axis";
grf.graph_x_label_color = 0x0;
grf.graph_x_major_length = 5;
grf.graph_x_major_tick = 20;
grf.graph_x_minor_length = 1;
grf.graph_x_minor_tick = 5;
grf.graph_xmax = 50;
grf.graph_xmin = -50;
/*
* Define the left y_axis display. Ignoring the right
* y_axis will display its default values.
*/
grf.graph_y_axis_color_left = 0x00bbaa;
grf.graph_y_axis_width_left = 2;
//grf.graph_y_font_left = "lu12";
grf.graph_y_font_left = "TextFont10";
grf.graph_y_label_color_left = 0x0;
grf.graph_y_label_left = "Left";
grf.graph_y_major_length_left = 3;
grf.graph_y_major_tick_left = 10.3;
grf.graph_y_minor_length_left = 1;
grf.graph_y_minor_tick_left = 5.3;
grf.graph_ymax_left = 125.3;
grf.graph_ymin_left = -5;
/*
* Set up the traces. Each trace has its own
* y_axis limits, color, and points.
*/
CwGraphSetYLimits(grf,0,-10,10);
CwGraphSetTraceColor(grf,0,0x0);
CwGraphAddXYPoints(grf,0,list(0,13.7,155),list(0,1.3,30));
CwGraphSetYLimits(grf,1,-10,10);
CwGraphSetTraceColor(grf,1,0xaa00aa);
CwGraphAddXYPoints(grf,1,list(-45,-30,0,30,45),list(0,-7,-9,-7,0));
CwGraphSetYLimits(grf,2,-10,10);
CwGraphSetTraceColor(grf,2,0x0000ff);
CwGraphAddXYPoints(grf,2,list(0,20,45,0,-25,-10,0),list(-1.5,-2.5,2.5,3,1.5,0,-1.5));
/*
* Print the results of various functions as examples.
*/
princ("Trace 0 data: ",CwGraphGetTraceData(grf,0,1,1),"\n");
princ("Trace 0 screen data: ",CwGraphGetScreenData(grf,0,1,1),"\n");
princ("Trace 0 length: ",CwGraphGetTraceLength(grf,0),"\n");
princ("Trace 1 length: ",CwGraphGetTraceLength(grf,1),"\n");
princ("Trace 2 length: ",CwGraphGetTraceLength(grf,2),"\n");
PtRealizeWidget(win);
PtMainLoop();
Also see A CwGraph Rotating Cube in the Sample Code and Cool Stuff chapter of the Programmer's Manual for a more sophisticated example.