home *** CD-ROM | disk | FTP | other *** search
- /* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
- #include <stdio.h>
- #define EXTERN extern
- #include <typedef.h>
-
-
- void PieHistoDem()
- {
- extern char *strcpy();
-
- double sum,x1,y1,x2,y2,InRadius,OutRadius;
- int i,n;
- PieArray a;
- PlotArray b;
- int ch;
- WrkString NumText;
- char string[80];
-
- n = 5;
- a[0].area = 25;
- a[1].area = 17.5;
- a[2].area = 9.6;
- a[3].area = 21;
- a[4].area = 35;
- strcpy(a[0].text, "JAN. ");
- strcpy(a[1].text, "FEB. ");
- strcpy(a[2].text, "MAR. ");
- strcpy(a[3].text, "APR. ");
- strcpy(a[4].text, "MAY ");
-
- for (i = 0; i < n; i++)
- b[1 + 2 * i] = a[i].area;
-
- ClearScreen();
- SetColorWhite();
-
- DefineWindow(1,0,0,XMaxGlb,YMaxGlb);
- DefineHeader(1,"BOTH A PIE AND A BAR CHART");
- SelectWindow(1);
- SetHeaderOn();
- SetBackground(0);
- DrawBorder();
-
- for (i = 0; i < n; i++) {
- GotoXY(60, 3+i);
- sprintf(string, "%s=%6.2lf", a[i].text, a[i].area);
- DisplayString(string);
- }
-
- DefineWindow(2,(int)(XMaxGlb/10),(int)(YMaxGlb/10),
- (int)(XMaxGlb*6/10),(int)(YMaxGlb*7/10));
- DefineHeader(2,"A PIE CHART");
- DefineWorld(2, 0., 0., 1000., 1000.);
- SelectWorld(2);
- SelectWindow(2);
- SetHeaderOn();
- SetBackground(0);
- DrawBorder();
-
-
- a[0].area = -a[0].area;
- SetAspect(1.0);
-
- x1 = 500.;
- y1 = 500.;
-
- x2 = 600.;
- y2 = 350.;
-
- InRadius = 0.7;
- OutRadius = 1.25;
-
- DrawCartPie(x1,y1,x2,y2,InRadius,OutRadius,a,n,2,1);
-
- a[0].area = -a[0].area;
-
- DefineWindow(3,(int)(XMaxGlb/2),(int)(YMaxGlb/2),
- (int)(XMaxGlb*9/10),(int)(YMaxGlb*9/10));
- DefineHeader(3,"A BAR CHART");
- DefineWorld(3, 0., 0., 10., 60.);
- SelectWorld(3);
- SelectWindow(3);
- SetHeaderOn();
- SetBackground(0);
- DrawBorder();
-
- DrawHistogram(b,n,TRUE,5);
-
- for (i = 0; i < n; i++) {
- sprintf(string, " %s", a[i].text);
- DrawTextW((double)(10/n)*i,(double)10,1,string);
- sprintf(string, "%6.2lf", a[i].area);
- DrawTextW((double)(10/n)*i,(double)16,1,string);
- }
- }
-
-
-
- main()
- {
- InitGraphic();
- PieHistoDem();
- inkey();
- LeaveGraphic();
- }
-