home *** CD-ROM | disk | FTP | other *** search
- /* This program will draw 6-slice 3D pie chart */
- #include "stdio.h"
- #include "conio.h"
- #include "eg_proto.h"
-
- int val[6]={5,4,3,2,3,2};
- extern int main(void );
-
- main() {
- int num=10,den=25; /* aspect ratio */
- int e=24,off=40; /* exploded the 4th and 5th slices by 40 pixels */
- int width=30; /* width of the pie */
- int pos=3; /* position of the labels, in this case no label
- but legend */
- int tdnpie=6; /* pie which has 6 slices */
- int radius=150,x0=320,y0=165; /* data for the pie */
- int location=9; /* location where to put the legend */
- int border=1; /* border for the legend */
- int linec=12,labelc=12;
- int i,fn=0,fn1=1; /* bit map font */
- int titlec=12; /* color for the title */
- int borderc=12; /* border's color of the pie */
- struct vfont *vfn; /* vector font to use */
-
- /* set the EGA mode 16 */
- setega();
- initgraf(16,0,0);
-
- /* set the world coordinate */
- setview(0,0,639,349);
- setworld(0,0,639,349);
- worldon(1);
-
- /* load the ibmrom */
- fontinit();
- if ((font_load(fn,"ibmrom"))!=0) {
- printf("Wrong from loading ibmrom\n");
- exit(0);
- }
- if ((font_load(fn1,"roman3.sms"))!=0) {
- printf("Wrong from loading ibmrom\n");
- exit(0);
- }
-
- /* set aspect ratio */
- setaspec(num,den);
-
- /* using the default hatching style */
- color_hatch();
-
- /* set 3D pie */
- i = td_pie_set(tdnpie,fn,pos,width,linec,labelc);
- td_pie_legend(location,border);
- /* for labeling */
- td_pie_slice(0,1,1,"Jan-Feb");
- td_pie_slice(1,2,2,"Mar-Apr");
- td_pie_slice(2,3,3,"May-Jun");
- td_pie_slice(3,4,4,"Jul-Aug");
- td_pie_slice(4,5,5,"Sep-Oct");
- td_pie_slice(5,6,6,"Nov-Dec");
-
- /* put the title */
- td_title(TOP,"South Mountain Software",titlec,fn1,vfn);
-
- /* for the 3D pie */
- i = td_pie(x0,y0,radius,e,borderc,off,val);
-
- /* free fonts */
- fontquit();
-
- /* return to the text mode */
- getch();
- initgraf(3,0,0);
- return(0);
- }
-