Пример #1
0
main( )
{
    /* set data - can be loaded from anywhere, e.g., a DB */
    float          data[6]  = { 20.0,     40.0,     25.0,       15.0,     9.0,      11.0 };      /* data array */
    char           *lbls[6] = { "Radio",  "Print",  "Internet", "TV",     "Cable",  "other" };   /* label array */
    /* optional data */
    int            expl[6]  = { 0,        0,        18,         0,        0,        21 };        /* explode each slice */
    unsigned long  clrs[6]  = { 0xFF0000, 0x00FF00, 0x0000FF,   0xFF00FF, 0xFFFF00, 0x00FFFF };  /* color for each slice */

                                        /* open FILE* (can be stdout e.g. CGI use) */
    FILE           *fp = fopen( "3dpie.gif", "wb" );


    /* set some options - not required */
    GDCPIE_explode   = expl;            /* default - no explosion */
    GDCPIE_Color     = clrs;            /* default - gray */
    GDCPIE_EdgeColor = 0xFFFFFFL;       /* default - no edging */

    /* call the lib */
    pie_gif( 200,                       /* width             */
             175,                       /* height            */
             fp,                        /* open file pointer */
             GDC_3DPIE,                 /* or GDC_2DPIE      */
             6,                         /* number of slices  */
             lbls,                      /* slice labels      */
             data );                    /* data array        */

    fclose( fp );
    exit( 0 );
}
Пример #2
0
main( int argc, char *argv[] )
{
	/* labels */
	char		*lbl[] = { "CPQ\n(DEC)",
						   "HP",
						   "SCO",
						   "IBM",
						   "SGI",
						   "SUN\nSPARC",
						   "other" }; 
	/* values to chart */
	float		 p[] = { 12.5,
						 20.1,
						 2.0,
						 22.0,
						 5.0,
						 18.0,
						 13.0 };

	FILE		*fp = fopen( "pie.gif", "wb" );

	/* set which slices to explode, and by how much */
	int				expl[] = { 0, 0, 0, 0, 0, 20, 0 };

	/* set missing slices */
	unsigned char	missing[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE };

	/* colors */
	unsigned long	clr[] = { 0xFF4040L, 0x80FF80L, 0x8080FFL, 0xFF80FFL, 0xFFFF80L, 0x80FFFFL, 0x0080FFL };

	/* set options  */
	/* a lot of options are set here for illustration */
	/* none need be - see gdcpie.h for defaults */
	GDCPIE_title = "Sample\nPIE";
	GDCPIE_label_line = TRUE;
	GDCPIE_label_dist = 15;				/* dist. labels to slice edge */
										/* can be negative */
	GDCPIE_LineColor = 0x000000L;
	GDCPIE_label_size = GDC_SMALL;
/*	GDCPIE_3d_depth  = 25;	*/
/*	GDCPIE_3d_angle  = 45;				   0 - 359 */
	GDCPIE_explode   = expl;			/* default: NULL - no explosion */
	GDCPIE_Color     = clr;
	GDCPIE_BGColor   = 0xFFFFFFL;
	GDCPIE_EdgeColor = 0x000000L;		/* default is GDCPIE_NOCOLOR */
										/* for no edging */
	GDCPIE_missing   = missing;			/* default: NULL - none missing */

										/* add percentage to slice label */
										/* below the slice label */
	GDCPIE_percent_labels = GDCPIE_PCT_RIGHT;

	/* call the lib */
	pie_gif( 480,			/* width */
			 360,			/* height */
			 fp,			/* open file pointer */
			 GDC_3DPIE,		/* or GDC_2DPIE */
			 7,				/* number of slices */
			 lbl,			/* slice labels (unlike out_gif(), can be NULL */
			 p );			/* data array */

	fclose( fp );
	exit( 0 );
}