gdc_pie_samp.c

Go to the documentation of this file.
00001 /* GDCHART 0.94b  PIE CHART SAMPLE  12 Nov 1998 */
00002 
00003 /* creates a file "pie.gif".  Can be stdout for CGI use. */
00004 /*  vi: :set tabstop=4 */
00005 
00006 #include <stdio.h>
00007 #include <values.h>
00008 #include <math.h>
00009 
00010 #include "gdc.h"
00011 #include "gdcpie.h"
00012 
00013 main( int argc, char *argv[] )
00014 {
00015         /* labels */
00016         char            *lbl[] = { "CPQ\n(DEC)",
00017                                                    "HP",
00018                                                    "SCO",
00019                                                    "IBM",
00020                                                    "SGI",
00021                                                    "SUN\nSPARC",
00022                                                    "other" }; 
00023         /* values to chart */
00024         float            p[] = { 12.5,
00025                                                  20.1,
00026                                                  2.0,
00027                                                  22.0,
00028                                                  5.0,
00029                                                  18.0,
00030                                                  13.0 };
00031 
00032         FILE            *fp = fopen( "pie.gif", "wb" );
00033 
00034         /* set which slices to explode, and by how much */
00035         int                             expl[] = { 0, 0, 0, 0, 0, 20, 0 };
00036 
00037         /* set missing slices */
00038         unsigned char   missing[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE };
00039 
00040         /* colors */
00041         unsigned long   clr[] = { 0xFF4040L, 0x80FF80L, 0x8080FFL, 0xFF80FFL, 0xFFFF80L, 0x80FFFFL, 0x0080FFL };
00042 
00043         /* set options  */
00044         /* a lot of options are set here for illustration */
00045         /* none need be - see gdcpie.h for defaults */
00046         GDCPIE_title = "Sample\nPIE";
00047         GDCPIE_label_line = TRUE;
00048         GDCPIE_label_dist = 15;                         /* dist. labels to slice edge */
00049                                                                                 /* can be negative */
00050         GDCPIE_LineColor = 0x000000L;
00051         GDCPIE_label_size = GDC_SMALL;
00052 /*      GDCPIE_3d_depth  = 25;  */
00053 /*      GDCPIE_3d_angle  = 45;                             0 - 359 */
00054         GDCPIE_explode   = expl;                        /* default: NULL - no explosion */
00055         GDCPIE_Color     = clr;
00056         GDCPIE_BGColor   = 0xFFFFFFL;
00057         GDCPIE_EdgeColor = 0x000000L;           /* default is GDCPIE_NOCOLOR */
00058                                                                                 /* for no edging */
00059         GDCPIE_missing   = missing;                     /* default: NULL - none missing */
00060 
00061                                                                                 /* add percentage to slice label */
00062                                                                                 /* below the slice label */
00063         GDCPIE_percent_labels = GDCPIE_PCT_RIGHT;
00064 
00065         /* call the lib */
00066         pie_gif( 480,                   /* width */
00067                          360,                   /* height */
00068                          fp,                    /* open file pointer */
00069                          GDC_3DPIE,             /* or GDC_2DPIE */
00070                          7,                             /* number of slices */
00071                          lbl,                   /* slice labels (unlike out_gif(), can be NULL */
00072                          p );                   /* data array */
00073 
00074         fclose( fp );
00075         exit( 0 );
00076 }

Generated on Sat Dec 15 00:00:57 2007 for BulmaGes by  doxygen 1.5.1