ruby-gdchart 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +81 -0
- data/README +47 -0
- data/examples/bar_example.rb +23 -0
- data/examples/line_example.rb +27 -0
- data/examples/pie_example.rb +19 -0
- data/ext/extconf.rb +35 -0
- data/ext/gdchart.c +1123 -0
- data/ext/gdchart0.11.5dev/Makefile +145 -0
- data/ext/gdchart0.11.5dev/README.txt +87 -0
- data/ext/gdchart0.11.5dev/array_alloc.c +183 -0
- data/ext/gdchart0.11.5dev/array_alloc.h +41 -0
- data/ext/gdchart0.11.5dev/ft_samp.c +89 -0
- data/ext/gdchart0.11.5dev/ft_samp.sav +89 -0
- data/ext/gdchart0.11.5dev/gdc.c +310 -0
- data/ext/gdchart0.11.5dev/gdc.h +158 -0
- data/ext/gdchart0.11.5dev/gdc_pie.c +691 -0
- data/ext/gdchart0.11.5dev/gdc_pie_samp.c +77 -0
- data/ext/gdchart0.11.5dev/gdc_samp1.c +47 -0
- data/ext/gdchart0.11.5dev/gdc_samp2.c +88 -0
- data/ext/gdchart0.11.5dev/gdchart.c +2193 -0
- data/ext/gdchart0.11.5dev/gdchart.h +248 -0
- data/ext/gdchart0.11.5dev/gdcpie.h +85 -0
- data/ext/gdchart0.11.5dev/price_conv.c +93 -0
- metadata +67 -0
@@ -0,0 +1,248 @@
|
|
1
|
+
/* GDCHART 0.10.0dev GDCHART.H 2 Nov 2000 */
|
2
|
+
/* Copyright Bruce Verderaime 1998-2004 */
|
3
|
+
|
4
|
+
#ifndef _GDCHART_H
|
5
|
+
#define _GDCHART_H
|
6
|
+
|
7
|
+
#ifndef _GDC_H
|
8
|
+
#include "gdc.h"
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#define MAX_NOTE_LEN 19
|
12
|
+
#define GDC_INTERP_VALUE (GDC_NOVALUE/2.0) /* must set GDC_interpolations */
|
13
|
+
#define GDC_INTERP ((GDC_interpolations=TRUE),GDC_INTERP_VALUE)
|
14
|
+
|
15
|
+
|
16
|
+
typedef enum {
|
17
|
+
GDC_LINE,
|
18
|
+
GDC_AREA,
|
19
|
+
GDC_BAR,
|
20
|
+
GDC_FLOATINGBAR,
|
21
|
+
GDC_HILOCLOSE,
|
22
|
+
GDC_COMBO_LINE_BAR, /* aka, VOL[ume] */
|
23
|
+
GDC_COMBO_HLC_BAR,
|
24
|
+
GDC_COMBO_LINE_AREA,
|
25
|
+
GDC_COMBO_LINE_LINE,
|
26
|
+
GDC_COMBO_HLC_AREA,
|
27
|
+
GDC_3DHILOCLOSE,
|
28
|
+
GDC_3DCOMBO_LINE_BAR,
|
29
|
+
GDC_3DCOMBO_LINE_AREA,
|
30
|
+
GDC_3DCOMBO_LINE_LINE,
|
31
|
+
GDC_3DCOMBO_HLC_BAR,
|
32
|
+
GDC_3DCOMBO_HLC_AREA,
|
33
|
+
GDC_3DBAR,
|
34
|
+
GDC_3DFLOATINGBAR,
|
35
|
+
GDC_3DAREA,
|
36
|
+
GDC_3DLINE
|
37
|
+
} GDC_CHART_T;
|
38
|
+
|
39
|
+
typedef enum {
|
40
|
+
GDC_STACK_DEPTH, /* "behind" (even non-3D) */
|
41
|
+
GDC_STACK_SUM,
|
42
|
+
GDC_STACK_BESIDE,
|
43
|
+
GDC_STACK_LAYER
|
44
|
+
} GDC_STACK_T; /* applies only to num_lines > 1 */
|
45
|
+
|
46
|
+
typedef enum {
|
47
|
+
GDC_HLC_DIAMOND = 1,
|
48
|
+
GDC_HLC_CLOSE_CONNECTED = 2, /* can't be used w/ CONNECTING */
|
49
|
+
GDC_HLC_CONNECTING = 4, /* can't be used w/ CLOSE_CONNECTED */
|
50
|
+
GDC_HLC_I_CAP = 8
|
51
|
+
} GDC_HLC_STYLE_T; /* can be OR'd */
|
52
|
+
|
53
|
+
/* only 1 annotation allowed */
|
54
|
+
typedef struct
|
55
|
+
{
|
56
|
+
float point; /* 0 <= point < num_points */
|
57
|
+
unsigned long color;
|
58
|
+
char note[MAX_NOTE_LEN+1]; /* NLs ok here */
|
59
|
+
} GDC_ANNOTATION_T;
|
60
|
+
|
61
|
+
typedef enum {
|
62
|
+
GDC_SCATTER_TRIANGLE_DOWN,
|
63
|
+
GDC_SCATTER_TRIANGLE_UP,
|
64
|
+
GDC_SCATTER_CIRCLE
|
65
|
+
} GDC_SCATTER_IND_T;
|
66
|
+
typedef struct
|
67
|
+
{
|
68
|
+
float point; /* 0 <= point < num_points */
|
69
|
+
float val;
|
70
|
+
unsigned short width; /* % (1-100) */
|
71
|
+
unsigned long color;
|
72
|
+
GDC_SCATTER_IND_T ind;
|
73
|
+
} GDC_SCATTER_T;
|
74
|
+
|
75
|
+
typedef enum {
|
76
|
+
GDC_TICK_LABELS = -2, /* only at labels */
|
77
|
+
GDC_TICK_POINTS = -1, /* each num_points */
|
78
|
+
GDC_TICK_NONE = 0
|
79
|
+
/* > GDC_TICK_NONE */ /* points & inter-point */
|
80
|
+
} GDC_TICK_T;
|
81
|
+
|
82
|
+
typedef enum { /* backward compatible w/ FALSE/TRUE */
|
83
|
+
GDC_BORDER_NONE = 0,
|
84
|
+
GDC_BORDER_ALL = 1, /* should be GDC_BORDER_Y|Y2|X|TOP */
|
85
|
+
GDC_BORDER_X = 2,
|
86
|
+
GDC_BORDER_Y = 4,
|
87
|
+
GDC_BORDER_Y2 = 8,
|
88
|
+
GDC_BORDER_TOP = 16
|
89
|
+
} GDC_BORDER_T;
|
90
|
+
|
91
|
+
/****************************************************/
|
92
|
+
/********** USER CHART OPTIONS w/ defaults **********/
|
93
|
+
/****************************************************/
|
94
|
+
EXTERND char *GDC_ytitle;
|
95
|
+
EXTERND char *GDC_xtitle;
|
96
|
+
EXTERND char *GDC_ytitle2; /* ostesibly: volume label */
|
97
|
+
EXTERND char *GDC_title; /* NLs ok here */
|
98
|
+
EXTERND enum GDC_font_size GDC_title_size DEFAULTO( GDC_MEDBOLD );
|
99
|
+
EXTERND enum GDC_font_size GDC_ytitle_size DEFAULTO( GDC_MEDBOLD );
|
100
|
+
EXTERND enum GDC_font_size GDC_xtitle_size DEFAULTO( GDC_MEDBOLD );
|
101
|
+
EXTERND enum GDC_font_size GDC_yaxisfont_size DEFAULTO( GDC_SMALL );
|
102
|
+
EXTERND enum GDC_font_size GDC_xaxisfont_size DEFAULTO( GDC_SMALL );
|
103
|
+
EXTERND double GDC_xaxis_angle DEFAULTO( 90.0 ); /* 0,90. FT: 0-90 */
|
104
|
+
#ifdef HAVE_LIBFREETYPE
|
105
|
+
EXTERND char *GDC_title_font DEFAULTO( NULL );
|
106
|
+
EXTERND char *GDC_ytitle_font DEFAULTO( NULL );
|
107
|
+
EXTERND char *GDC_xtitle_font DEFAULTO( NULL );
|
108
|
+
EXTERND char *GDC_yaxis_font DEFAULTO( NULL );
|
109
|
+
EXTERND char *GDC_xaxis_font DEFAULTO( NULL );
|
110
|
+
EXTERND double GDC_title_ptsize DEFAULTO( 0.0 );
|
111
|
+
EXTERND double GDC_ytitle_ptsize DEFAULTO( 0.0 );
|
112
|
+
EXTERND double GDC_xtitle_ptsize DEFAULTO( 0.0 );
|
113
|
+
EXTERND double GDC_yaxis_ptsize DEFAULTO( 0.0 );
|
114
|
+
EXTERND double GDC_xaxis_ptsize DEFAULTO( 0.0 );
|
115
|
+
#endif
|
116
|
+
EXTERND char *GDC_ylabel_fmt DEFAULTO( NULL ); /* printf fmt'ing, e.g.: "%.2f" */
|
117
|
+
EXTERND char *GDC_ylabel2_fmt DEFAULTO( NULL ); /* default: "%.0f" future: fractions */
|
118
|
+
EXTERND char *GDC_xlabel_ctl DEFAULTO( NULL ); /* num_points[] TRUE,FALSE */
|
119
|
+
EXTERND short GDC_xlabel_spacing DEFAULTO( 5 ); /* pixels SHRT_MAX means force all */
|
120
|
+
EXTERND char GDC_ylabel_density DEFAULTO( 80 ); /* % */
|
121
|
+
EXTERND char GDC_interpolations DEFAULTO( FALSE ); /* GDC_INTERP_VALUE in data */
|
122
|
+
EXTERND float GDC_requested_ymin DEFAULTO( GDC_NOVALUE );
|
123
|
+
EXTERND float GDC_requested_ymax DEFAULTO( GDC_NOVALUE );
|
124
|
+
EXTERND float GDC_requested_yinterval DEFAULTO( GDC_NOVALUE );
|
125
|
+
EXTERND char GDC_0Shelf DEFAULTO( TRUE ); /* if applicable */
|
126
|
+
EXTERND GDC_TICK_T GDC_grid DEFAULTO( GDC_TICK_LABELS );
|
127
|
+
EXTERND GDC_TICK_T GDC_ticks DEFAULTO( GDC_TICK_LABELS );
|
128
|
+
EXTERND char GDC_xaxis DEFAULTO( TRUE );
|
129
|
+
EXTERND char GDC_yaxis DEFAULTO( TRUE );
|
130
|
+
EXTERND char GDC_yaxis2 DEFAULTO( TRUE );
|
131
|
+
EXTERND char GDC_yval_style DEFAULTO( TRUE );
|
132
|
+
EXTERND GDC_STACK_T GDC_stack_type DEFAULTO( GDC_STACK_DEPTH );
|
133
|
+
EXTERND float GDC_3d_depth DEFAULTO( 5.0 ); /* % img size */
|
134
|
+
EXTERND unsigned char GDC_3d_angle DEFAULTO( 45 ); /* 1-89 */
|
135
|
+
EXTERND unsigned char GDC_bar_width DEFAULTO( 75 ); /* % (1-100) */
|
136
|
+
EXTERND GDC_HLC_STYLE_T GDC_HLC_style DEFAULTO( GDC_HLC_CLOSE_CONNECTED );
|
137
|
+
EXTERND unsigned char GDC_HLC_cap_width DEFAULTO( 25 ); /* % (1-100) */
|
138
|
+
EXTERND GDC_ANNOTATION_T *GDC_annotation DEFAULTO( (GDC_ANNOTATION_T*)NULL );
|
139
|
+
EXTERND enum GDC_font_size GDC_annotation_font_size DEFAULTO( GDC_SMALL );
|
140
|
+
#ifdef HAVE_LIBFREETYPE
|
141
|
+
EXTERND char *GDC_annotation_font DEFAULTO( NULL );
|
142
|
+
EXTERND double GDC_annotation_ptsize DEFAULTO( 0.0 );
|
143
|
+
#endif
|
144
|
+
EXTERND int GDC_num_scatter_pts DEFAULTO( 0 );
|
145
|
+
EXTERND GDC_SCATTER_T *GDC_scatter DEFAULTO( (GDC_SCATTER_T*)NULL );
|
146
|
+
EXTERND char GDC_thumbnail DEFAULTO( FALSE );
|
147
|
+
EXTERND char *GDC_thumblabel;
|
148
|
+
EXTERND float GDC_thumbval DEFAULTO( -FLT_MAX );
|
149
|
+
EXTERND GDC_BORDER_T GDC_border DEFAULTO( GDC_BORDER_ALL );
|
150
|
+
EXTERND unsigned long GDC_BGColor DEFAULTO( 0x000000L ); /* black */
|
151
|
+
EXTERND unsigned long GDC_GridColor DEFAULTO( 0xA0A0A0L ); /* gray */
|
152
|
+
EXTERND unsigned long GDC_LineColor DEFAULTO( GDC_DFLTCOLOR );
|
153
|
+
EXTERND unsigned long GDC_PlotColor DEFAULTO( GDC_DFLTCOLOR );
|
154
|
+
EXTERND unsigned long GDC_VolColor DEFAULTO( 0xA0A0FFL ); /* lgtblue1 */
|
155
|
+
EXTERND unsigned long GDC_TitleColor DEFAULTO( GDC_DFLTCOLOR ); /* "opposite" of BG */
|
156
|
+
EXTERND unsigned long GDC_XTitleColor DEFAULTO( GDC_DFLTCOLOR );
|
157
|
+
EXTERND unsigned long GDC_YTitleColor DEFAULTO( GDC_DFLTCOLOR );
|
158
|
+
EXTERND unsigned long GDC_YTitle2Color DEFAULTO( GDC_DFLTCOLOR );
|
159
|
+
EXTERND unsigned long GDC_XLabelColor DEFAULTO( GDC_DFLTCOLOR );
|
160
|
+
EXTERND unsigned long GDC_YLabelColor DEFAULTO( GDC_DFLTCOLOR );
|
161
|
+
EXTERND unsigned long GDC_YLabel2Color DEFAULTO( GDC_DFLTCOLOR );
|
162
|
+
/* supercedes VolColor ulong_color[num_points] */
|
163
|
+
EXTERND unsigned long *GDC_ExtVolColor DEFAULTO( (unsigned long*)NULL );
|
164
|
+
/* supercedes LineColor ulong_color[num_sets] */
|
165
|
+
EXTERND unsigned long *GDC_SetColor DEFAULTO( (unsigned long*)NULL );
|
166
|
+
/* supercedes SetColor ulong_color[num_sets][num_points] */
|
167
|
+
EXTERND unsigned long *GDC_ExtColor DEFAULTO( (unsigned long*)NULL );
|
168
|
+
EXTERND char GDC_transparent_bg DEFAULTO( FALSE );
|
169
|
+
EXTERND char *GDC_BGImage DEFAULTO( (char*)NULL );
|
170
|
+
/* legends? separate img? */
|
171
|
+
/* auto-size fonts, based on image size? */
|
172
|
+
|
173
|
+
/* ----- following options are for expert users only ----- */
|
174
|
+
/* for alignment of multiple charts */
|
175
|
+
/* USE WITH CAUTION! */
|
176
|
+
EXTERND char GDC_hard_size DEFAULTO( FALSE );
|
177
|
+
EXTERND int GDC_hard_xorig DEFAULTO( 0 ); /* in/out */
|
178
|
+
EXTERND int GDC_hard_graphwidth DEFAULTO( 0 ); /* in/out */
|
179
|
+
EXTERND int GDC_hard_yorig DEFAULTO( 0 ); /* in/out */
|
180
|
+
EXTERND int GDC_hard_grapheight DEFAULTO( 0 ); /* in/out */
|
181
|
+
|
182
|
+
/**** COMMON OPTIONS ********************************/
|
183
|
+
/* NOTE: common options copy here for reference only! */
|
184
|
+
/* they live in gdc.h */
|
185
|
+
#ifndef _GDC_COMMON_OPTIONS
|
186
|
+
#define _GDC_COMMON_OPTIONS
|
187
|
+
EXTERND char GDC_generate_img DEFAULTO( TRUE );
|
188
|
+
|
189
|
+
EXTERND GDC_HOLD_IMAGE_T GDC_hold_img DEFAULTO( GDC_DESTROY_IMAGE );
|
190
|
+
EXTERND void *GDC_image DEFAULTO( (void*)NULL ); /* in/out */
|
191
|
+
#endif
|
192
|
+
/****************************************************/
|
193
|
+
|
194
|
+
#ifdef GDC_LIB
|
195
|
+
#define clrallocate( im, rawclr ) _clrallocate( im, rawclr, GDC_BGColor )
|
196
|
+
#define clrshdallocate( im, rawclr ) _clrshdallocate( im, rawclr, GDC_BGColor )
|
197
|
+
#endif
|
198
|
+
|
199
|
+
int GDC_out_graph( short IMGWIDTH, /* no check for a image that's too small to fit */
|
200
|
+
short IMGHEIGHT,
|
201
|
+
FILE *img_fptr, /* open file pointer (iamge out) stdout ok */
|
202
|
+
GDC_CHART_T type,
|
203
|
+
int num_points, /* points along x axis (even iterval) */
|
204
|
+
/* all arrays dependant on this */
|
205
|
+
char *xlbl[], /* array of xlabels */
|
206
|
+
int num_sets,
|
207
|
+
float *data, /* based on num_sets X num_points */
|
208
|
+
float *combo_data ); /* only used on COMBO chart types */
|
209
|
+
/* ----- backward compatible var arg interface ----- */
|
210
|
+
int out_graph( short imgwidth,
|
211
|
+
short imgheight,
|
212
|
+
FILE *img_fptr, /* open file pointer (image out) */
|
213
|
+
GDC_CHART_T type,
|
214
|
+
int num_points, /* points along x axis (even iterval) */
|
215
|
+
char *xlbl[],
|
216
|
+
int num_sets,
|
217
|
+
... );
|
218
|
+
/* expected params (...) for each chart type:
|
219
|
+
GDC_LINE
|
220
|
+
GDC_BAR
|
221
|
+
GDC_3DBAR
|
222
|
+
GDC_3DAREA
|
223
|
+
GDC_AREA float vals[], ...
|
224
|
+
multiple sets make sense for rest?
|
225
|
+
GDC_HILOCLOSE float high[],
|
226
|
+
float low[],
|
227
|
+
float close[]
|
228
|
+
|
229
|
+
GDC_COMBO_LINE_BAR
|
230
|
+
GDC_COMBO_LINE_AREA float val[],
|
231
|
+
float vol[]
|
232
|
+
|
233
|
+
GDC_COMBO_HLC_BAR
|
234
|
+
GDC_COMBO_HLC_AREA float high[],
|
235
|
+
float low[],
|
236
|
+
float close[],
|
237
|
+
float vol[]
|
238
|
+
|
239
|
+
*/
|
240
|
+
|
241
|
+
/* Notes:
|
242
|
+
GDC_thumbnail = TRUE
|
243
|
+
is equivelent to: GDC_grid = FALSE
|
244
|
+
GDC_xaxis = FALSE
|
245
|
+
GDC_yaxis = FALSE
|
246
|
+
*/
|
247
|
+
|
248
|
+
#endif /*!_GDCHART_H*/
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/* GDCHART 0.10.0dev GDCHART.H 2 Nov 2000 */
|
2
|
+
/* Copyright Bruce Verderaime 1998-2004 */
|
3
|
+
|
4
|
+
#ifndef _GDCPIE_H
|
5
|
+
#define _GDCPIE_H
|
6
|
+
|
7
|
+
#ifndef _GDC_H
|
8
|
+
#include "gdc.h"
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#ifdef GDC_LIB
|
12
|
+
extern struct GDC_FONT_T GDC_fontc[];
|
13
|
+
#endif
|
14
|
+
|
15
|
+
typedef enum {
|
16
|
+
GDC_3DPIE,
|
17
|
+
GDC_2DPIE
|
18
|
+
} GDCPIE_TYPE;
|
19
|
+
|
20
|
+
typedef enum {
|
21
|
+
GDCPIE_PCT_NONE,
|
22
|
+
GDCPIE_PCT_ABOVE, /* relative to label, if any */
|
23
|
+
GDCPIE_PCT_BELOW,
|
24
|
+
GDCPIE_PCT_RIGHT,
|
25
|
+
GDCPIE_PCT_LEFT
|
26
|
+
} GDCPIE_PCT_TYPE;
|
27
|
+
|
28
|
+
|
29
|
+
/**************************************************/
|
30
|
+
/**** USER DEFINABLE PIE OPTIONS w/ defaults *****/
|
31
|
+
/**************************************************/
|
32
|
+
EXTERND unsigned long GDCPIE_BGColor DEFAULTO( 0x000000L ); /* black */
|
33
|
+
EXTERND unsigned long GDCPIE_PlotColor DEFAULTO( 0xC0C0C0L ); /* gray */
|
34
|
+
EXTERND unsigned long GDCPIE_LineColor DEFAULTO( GDC_DFLTCOLOR );
|
35
|
+
EXTERND unsigned long GDCPIE_EdgeColor DEFAULTO( GDC_NOCOLOR ); /* edging on/off */
|
36
|
+
|
37
|
+
EXTERND char GDCPIE_other_threshold DEFAULTO( -1 );
|
38
|
+
EXTERND unsigned short GDCPIE_3d_angle DEFAULTO( 45 ); /* 0-360 */
|
39
|
+
EXTERND unsigned short GDCPIE_3d_depth DEFAULTO( 10 ); /* % image width */
|
40
|
+
EXTERND unsigned short GDCPIE_perspective DEFAULTO( 0 ); /* % view */
|
41
|
+
EXTERND char *GDCPIE_title DEFAULTO( NULL ); /* NLs ok here */
|
42
|
+
EXTERND enum GDC_font_size GDCPIE_title_size DEFAULTO( GDC_MEDBOLD );
|
43
|
+
EXTERND enum GDC_font_size GDCPIE_label_size DEFAULTO( GDC_SMALL );
|
44
|
+
#ifdef HAVE_LIBFREETYPE
|
45
|
+
EXTERND char *GDCPIE_title_font DEFAULTO( NULL );
|
46
|
+
EXTERND char *GDCPIE_label_font DEFAULTO( NULL );
|
47
|
+
EXTERND double GDCPIE_title_ptsize DEFAULTO( 0.0 );
|
48
|
+
EXTERND double GDCPIE_label_ptsize DEFAULTO( 0.0 );
|
49
|
+
#endif
|
50
|
+
EXTERND int GDCPIE_label_dist DEFAULTO( 1+8/2 ); /* 1+GDC_fontc[GDCPIE_label_size].h/2 */
|
51
|
+
EXTERND unsigned char GDCPIE_label_line DEFAULTO( FALSE ); /* from label to slice */
|
52
|
+
|
53
|
+
EXTERND int *GDCPIE_explode DEFAULTO( (int*)NULL ); /* [num_points] */
|
54
|
+
/* [num_points] supercedes GDCPIE_PlotColor */
|
55
|
+
EXTERND unsigned long *GDCPIE_Color DEFAULTO( (unsigned long*)NULL );
|
56
|
+
EXTERND unsigned char *GDCPIE_missing DEFAULTO( (unsigned char*)NULL ); /* TRUE/FALSE */
|
57
|
+
|
58
|
+
EXTERND GDCPIE_PCT_TYPE GDCPIE_percent_labels DEFAULTO( GDCPIE_PCT_NONE );
|
59
|
+
EXTERND char *GDCPIE_percent_fmt DEFAULTO( "%.0f%%" ); /* printf fmt'ing */
|
60
|
+
/**** COMMON OPTIONS ******************************/
|
61
|
+
/* NOTE: common options copy here for reference only! */
|
62
|
+
/* they live in gdc.h */
|
63
|
+
#ifndef _GDC_COMMON_OPTIONS
|
64
|
+
#define _GDC_COMMON_OPTIONS
|
65
|
+
EXTERND char GDC_generate_img DEFAULTO( TRUE );
|
66
|
+
|
67
|
+
EXTERND GDC_HOLD_IMAGE_T GDC_hold_img DEFAULTO( GDC_DESTROY_IMAGE );
|
68
|
+
EXTERND void *GDC_image DEFAULTO( (void*)NULL ); /* in/out */
|
69
|
+
#endif
|
70
|
+
/**************************************************/
|
71
|
+
|
72
|
+
#ifdef GDC_LIB
|
73
|
+
#define clrallocate( im, rawclr ) _clrallocate( im, rawclr, GDCPIE_BGColor )
|
74
|
+
#define clrshdallocate( im, rawclr ) _clrshdallocate( im, rawclr, GDCPIE_BGColor )
|
75
|
+
#endif
|
76
|
+
|
77
|
+
void GDC_out_pie( short width,
|
78
|
+
short height,
|
79
|
+
FILE*, /* open file pointer, can be stdout */
|
80
|
+
GDCPIE_TYPE,
|
81
|
+
int num_points,
|
82
|
+
char *labels[], /* slice labels */
|
83
|
+
float data[] );
|
84
|
+
|
85
|
+
#endif /*!_GDCPIE_H*/
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/* GDCHART 0.10.0dev PRICE_CONV.C 2 Nov 2000 */
|
2
|
+
/* Copyright Bruce Verderaime 1998-2004 */
|
3
|
+
|
4
|
+
/*
|
5
|
+
* - price as float to a string (ostensibly for printing)
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <stdlib.h>
|
9
|
+
#include <stdio.h>
|
10
|
+
#include <ctype.h>
|
11
|
+
#include <math.h>
|
12
|
+
|
13
|
+
/* ----------------------------------------------------------------- */
|
14
|
+
/* -- convert a float to a printable string, in form: -- */
|
15
|
+
/* -- W N/D -- */
|
16
|
+
/* -- where W is whole, N is numerator, D is denominator -- */
|
17
|
+
/* -- the frac N/D is one of 2nds, 4,8,16,32,64,128,256ths -- */
|
18
|
+
/* -- if cannot convert, return str of the float -- */
|
19
|
+
/* ----------------------------------------------------------------- */
|
20
|
+
|
21
|
+
#define EPSILON ((1.0/256.0)/2.0)
|
22
|
+
#define GET_DEC(x) ( (x) - (float)(int)(x) )
|
23
|
+
|
24
|
+
char*
|
25
|
+
price_to_str( float price,
|
26
|
+
int *numorator,
|
27
|
+
int *demoninator,
|
28
|
+
int *decimal,
|
29
|
+
char *fltfmt ) /* printf fmt'ing str */
|
30
|
+
{
|
31
|
+
static char rtn[64];
|
32
|
+
int whole = (int)price;
|
33
|
+
float dec = GET_DEC( price ),
|
34
|
+
numr;
|
35
|
+
/* float pow( double, double ); */
|
36
|
+
|
37
|
+
/* caller doesn't want fractions */
|
38
|
+
if( fltfmt )
|
39
|
+
{
|
40
|
+
sprintf( rtn, fltfmt, price );
|
41
|
+
*numorator = *demoninator = *decimal = 0;
|
42
|
+
return rtn;
|
43
|
+
}
|
44
|
+
|
45
|
+
numr = dec * 256;
|
46
|
+
/* check if we have a perfect fration in 256ths */
|
47
|
+
{
|
48
|
+
float rdec = GET_DEC( numr );
|
49
|
+
|
50
|
+
if( rdec < EPSILON )
|
51
|
+
; /* close enough to frac */
|
52
|
+
else if( (1-rdec) < EPSILON ) /* just over but close enough */
|
53
|
+
++numr;
|
54
|
+
else /* no frac match */
|
55
|
+
{
|
56
|
+
sprintf( rtn, "%f", price );
|
57
|
+
*numorator = *demoninator = *decimal = 0;
|
58
|
+
return rtn;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
/* now have numr 256ths */
|
63
|
+
/* resolve down */
|
64
|
+
if( numr != 0 )
|
65
|
+
{
|
66
|
+
int cnt = 8;
|
67
|
+
|
68
|
+
while( (float)(numr)/2.0 == (float)(int)(numr/2) )
|
69
|
+
{
|
70
|
+
numr /= 2;
|
71
|
+
--cnt;
|
72
|
+
}
|
73
|
+
|
74
|
+
/* don't want both whole AND numerator to be - */
|
75
|
+
if( whole<0 && numr<0.0 )
|
76
|
+
numr = -numr;
|
77
|
+
*numorator = (int)numr;
|
78
|
+
*demoninator = (int)pow(2.0, (float)cnt);
|
79
|
+
*decimal = whole;
|
80
|
+
sprintf( rtn, "%d %d/%d", whole,
|
81
|
+
(int)numr,
|
82
|
+
*demoninator );
|
83
|
+
}
|
84
|
+
else
|
85
|
+
{
|
86
|
+
*numorator = *demoninator = 0;
|
87
|
+
*decimal = whole;
|
88
|
+
sprintf( rtn, "%d", whole );
|
89
|
+
}
|
90
|
+
|
91
|
+
return rtn;
|
92
|
+
}
|
93
|
+
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: ruby-gdchart
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2005-11-08 00:00:00 -05:00
|
8
|
+
summary: "A Ruby wrapper around Bruce Verderaime's GDChart chart-drawing utility. (Note:
|
9
|
+
The C library that this gem wraps is included, but requires the installation of
|
10
|
+
gd-2.0.28 or higher.)"
|
11
|
+
require_paths:
|
12
|
+
- "."
|
13
|
+
email: daniel.wislocki@gmail.com
|
14
|
+
homepage: http://daniel.wislocki.org/
|
15
|
+
rubyforge_project:
|
16
|
+
description:
|
17
|
+
autorequire: GDChart
|
18
|
+
default_executable:
|
19
|
+
bindir: bin
|
20
|
+
has_rdoc: false
|
21
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
+
requirements:
|
23
|
+
-
|
24
|
+
- ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.0
|
27
|
+
version:
|
28
|
+
platform: ruby
|
29
|
+
signing_key:
|
30
|
+
cert_chain:
|
31
|
+
authors:
|
32
|
+
- Daniel Wislocki
|
33
|
+
files:
|
34
|
+
- ext/extconf.rb
|
35
|
+
- ext/gdchart.c
|
36
|
+
- ext/gdchart0.11.5dev
|
37
|
+
- ext/gdchart0.11.5dev/array_alloc.c
|
38
|
+
- ext/gdchart0.11.5dev/array_alloc.h
|
39
|
+
- ext/gdchart0.11.5dev/ft_samp.c
|
40
|
+
- ext/gdchart0.11.5dev/ft_samp.sav
|
41
|
+
- ext/gdchart0.11.5dev/gdc.c
|
42
|
+
- ext/gdchart0.11.5dev/gdc.h
|
43
|
+
- ext/gdchart0.11.5dev/gdchart.c
|
44
|
+
- ext/gdchart0.11.5dev/gdchart.h
|
45
|
+
- ext/gdchart0.11.5dev/gdcpie.h
|
46
|
+
- ext/gdchart0.11.5dev/gdc_pie.c
|
47
|
+
- ext/gdchart0.11.5dev/gdc_pie_samp.c
|
48
|
+
- ext/gdchart0.11.5dev/gdc_samp1.c
|
49
|
+
- ext/gdchart0.11.5dev/gdc_samp2.c
|
50
|
+
- ext/gdchart0.11.5dev/Makefile
|
51
|
+
- ext/gdchart0.11.5dev/price_conv.c
|
52
|
+
- ext/gdchart0.11.5dev/README.txt
|
53
|
+
- examples/line_example.rb
|
54
|
+
- examples/pie_example.rb
|
55
|
+
- examples/bar_example.rb
|
56
|
+
- README
|
57
|
+
- ChangeLog
|
58
|
+
test_files: []
|
59
|
+
rdoc_options: []
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README
|
62
|
+
- ChangeLog
|
63
|
+
executables: []
|
64
|
+
extensions:
|
65
|
+
- ext/extconf.rb
|
66
|
+
requirements: []
|
67
|
+
dependencies: []
|