C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
BARCOL.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* BARCOL.C illustrates presentation graphics support routines and
 * single-series chart routines including:                        (DOS-only)
 *      _pg_initchart   _pg_chart       _pg_chartpie    _pg_defaultchart
 */
 
#include <conio.h>
#include <stdlib.h>
#include <graph.h>
#include <string.h>
#include <pgchart.h>
 
#define COUNTRIES 5
float __far value[COUNTRIES] =     { 42.5F,  14.3F, 35.2F,  21.3F, 32.6F   };
char  __far *category[COUNTRIES] = { "CAN",  "JAP", "USA",  "UK",  "Other" };
short __far explode[COUNTRIES] =   { 0,      1,     0,      1,     0       };
 
void main()
{
    _chartenv env;
 
    if( !_setvideomode( _MAXRESMODE ) )
        exit( 1 );
 
    _pg_initchart();                    /* Initialize chart system    */
 
    /* Single-series bar chart */
    _pg_defaultchart( &env, _PG_BARCHART, _PG_PLAINBARS );
    strcpy( env.maintitle.title, "Widget Production" );
    _pg_chart( &env, category, value, COUNTRIES );
    _getch();
    _clearscreen( _GCLEARSCREEN );
 
    /* Single-series column chart */
    _pg_defaultchart( &env, _PG_COLUMNCHART, _PG_PLAINBARS );
    strcpy( env.maintitle.title, "Widget Production" );
    _pg_chart( &env, category, value, COUNTRIES );
    _getch();
    _clearscreen( _GCLEARSCREEN );
 
    /* Pie chart */
    _pg_defaultchart( &env, _PG_PIECHART, _PG_PERCENT );
    strcpy( env.maintitle.title, "Widget Production" );
    _pg_chartpie( &env, category, value, explode, COUNTRIES );
    _getch();
 
    _setvideomode( _DEFAULTMODE );
}
                                    -♦-