_pg_analyzechart Functions

Description

Analyze a series of data.

#include <pgchart.h>

short __far _pg_analyzechart( _chartenv __far *env,
char __far * __far *categories, float __far *values, short n );

short __far _pg_analyzechartms( _chartenv __far *env,
char __far * __far *categories, float __far *values, short nseries, short n,
short arraydim, char __far * __far *serieslabels );

env Chart environment variable  
categories Array of category variables  
values Array of data values  
nseries Number of series to chart  
n Number of data values to chart  
arraydim Row dimension of data array  
serieslabels Array of labels for series  

Remarks

The _pg_analyzechart routines analyze a single or multiple series of data without actually displaying the presentation-graphic image.

The _pg_analyzechart function fills the chart environment with default values for a single-series bar, column, or line chart, depending on the type specified by the call to the _pg_defaultchart function. The variables calculated by _pg_analyzechart reflect the data given in the arguments categories and values. All arguments are the same as those used with the _pg_chart function.

The _pg_analyzechartms function fills the chart environment with default values for a multiseries bar, column, or line chart, depending on which type is specified in the _pg_defaultchart function. The variables calculated by _pg_analyzechartms reflect the data given in the arguments categories and values. All arguments are the same as those used with the _pg_chartms function.

Boolean flags in the chart environment, such as AUTOSCALE and LEGEND, should be set to TRUE before calling either _pg_analyzechart function. This will ensure that the function will calculate all defaults.

For a discussion of the chart environment and related topics, see “Presentation-Graphics Functions”.

Return Value

The _pg_analyzechart and _pg_analyzechartms functions return 0 if there were no errors. A nonzero value indicates a failure.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_pg_chart functions, _pg_defaultchart, _pg_initchart

Example

/* PGACHART.C: This example illustrates presentation-graphics

* analyze functions.

* The example uses

* _pg_analyzechartms

* The same principles apply for

* _pg_analyzepie _pg_analyzechart

* _pg_analyzescatter _pg_analyzescatterms

*/

#include <conio.h>

#include <string.h>

#include <stdlib.h>

#include <graph.h>

#include <pgchart.h>

#define FALSE 0

#define TRUE 1

/* Note data declared as a single-dimension array. The multiseries

* chart functions expect only one dimension. See _pg_chartms

* example for alternate method using multidimension array.

*/

#define TEAMS 4

#define MONTHS 3

float __far values[TEAMS * MONTHS] = { .435, .522, .671,

.533, .431, .590,

.723, .624, .488,

.329, .226, .401 };

char __far *months[MONTHS] = { "May", "June", "July" };

char __far *teams[TEAMS] = { "Reds", "Sox", "Cubs", "Mets" };

void main( void )

{

_chartenv env;

/* Find a valid graphics mode. */

if( !_setvideomode( _MAXRESMODE ) )

exit( 1 );

_pg_initchart(); /* Initialize chart system. */

/* Default multiseries bar chart */

_pg_defaultchart( &env, _PG_BARCHART, _PG_PLAINBARS );

strcpy( env.maintitle.title, "Little League Records - Default" );

_pg_chartms( &env, months, values, TEAMS, MONTHS, MONTHS, teams );

_getch();

_clearscreen( _GCLEARSCREEN );

/* Analyze multiseries bar chart with autoscale. This sets all

* default scale values. We want y axis values to be automatic.

*/

_pg_defaultchart( &env, _PG_BARCHART, _PG_PLAINBARS );

strcpy( env.maintitle.title, "Little League Records - Customized" );

env.xaxis.autoscale = TRUE;

_pg_analyzechartms( &env, months, values, TEAMS, MONTHS, MONTHS, teams );

/* Now customize some of the x axis values. Then draw the chart. */

env.xaxis.autoscale = FALSE;

env.xaxis.scalemax = 1.0; /* Make scale show 0.0 to 1.0. */

env.xaxis.ticinterval = 0.2; /* Don't make scale too crowded. */

env.xaxis.ticdecimals = 3; /* Show three decimals. */

strcpy( env.xaxis.scaletitle.title, "Win/Loss Percentage" );

_pg_chartms( &env, months, values, TEAMS, MONTHS, MONTHS, teams );

_getch();

_setvideomode( _DEFAULTMODE );

exit( 0 );

}