home *** CD-ROM | disk | FTP | other *** search
- #include "eg_grafx.h"
-
- /* function to draw a line graph */
-
- eg_line_graph(num_pts,pts,g_info,x_axis,y_axis)
- int num_pts; /* number of points to draw */
- int *pts; /* array of points */
- GRAPH_INFO g_info; /* graph description */
- EG_AXIS x_axis; /* X axis info */
- EG_AXIS y_axis; /* Y axis info */
- {
-
- int i,symbol_size;
- struct egstatus s; /* EG status structure */
- int x0,x1,y0,y1;
- int k,l;
-
- eg_status(&s); /* get EG status */
-
- /* switch Y coordinates */
- i = y_axis.high; y_axis.high = y_axis.low; y_axis.low = i;
-
- if (g_info.symbol_size == -1){
- worldpts(x_axis.low,y_axis.low,&x0,&y0);
- worldpts(x_axis.high,y_axis.high,&x1,&y1);
-
- if ( (y1 - y0) > (x1 - x0) )
- symbol_size = ((x1 - x0 + 1) - (num_pts*5) )/ (num_pts+5);
- else
- symbol_size = ((y1 - y0 + 1) - (num_pts*5) )/ (num_pts+5);
-
- symbol_size /= 2;
- }
- else
- symbol_size = g_info.symbol_size;
-
- /* minimum symbol size is 5 */
- if (symbol_size < 5)
- symbol_size = 5;
-
- /* draw the line and or symbol points */
- if (g_info.adjust_edges)
- set_base(1,pts[0]); /* set the starting base position */
- else
- set_base(0,pts[0]); /* set the starting base position */
-
- /* if not symbol only, draw line */
- if (g_info.line_graph_type != SYMBOL_ONLY){
- set_line_width(g_info.line_width); /* set the line width */
- set_line_style(g_info.line_style); /* set the line style */
- /* loop thru the number of lines to plot */
- if (g_info.adjust_edges){
- for (i = 0; i < num_pts; i++)
- eg_lineto(i+1,pts[i],g_info.item_color,0);
- }
- else
- for (i = 1; i < num_pts; i++)
- eg_lineto(i,pts[i],g_info.item_color,0);
- }
- /* reset the line width */
- set_line_width(s.line_width);
- /* reset the line style */
- set_line_style(s.line_style);
-
- /* if not line only, draw symbols at points */
- if (g_info.line_graph_type != LINE_ONLY)
- /* loop thru the number of points to plot */
- if (g_info.adjust_edges){
- for (i = 0; i < num_pts; i++)
- (*act_lg_symbol)(i+1,pts[i],symbol_size,g_info.symbol_color,g_info.symbol_fill);
- }
- else{
- for (i = 0; i < num_pts; i++){
- (*act_lg_symbol)(i,pts[i],symbol_size,g_info.symbol_color,g_info.symbol_fill);
- worldpts(i,pts[i],&k,&l);
- }
- }
- return(0);
- }
-