-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdc_pie_samp.c
77 lines (66 loc) · 2.66 KB
/
gdc_pie_samp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* GDCHART 0.10.0dev PIE SAMPLE 2 Nov 2000 */
/* Copyright Bruce Verderaime 1998-2004 */
/* creates a file "pie.png". Can be stdout for CGI use. */
/* vi: :set tabstop=4 */
#include <stdio.h>
#include <math.h>
#include "gdc.h"
#include "gdcpie.h"
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.png", "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 = 180; /* 0 - 359 */
GDCPIE_perspective = 70; /* 0 - 99 */
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_BELOW;
GDC_image_type = GDC_PNG;
/* call the lib */
GDC_out_pie( 300, /* width */
200, /* height */
fp, /* open file pointer */
GDC_3DPIE, /* or GDC_2DPIE */
7, /* number of slices */
NULL, /* can be NULL */
p ); /* data array */
fclose( fp );
exit( 0 );
}