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
data/ChangeLog
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
2005-11-01 Daniel Wislocki <daniel@silveregg.co.jp>
|
2
|
+
|
3
|
+
* ruby-gdchart.gemspec: Gemmification!
|
4
|
+
|
5
|
+
* extconf.rb: Upgraded to gdchart0.11.5dev.
|
6
|
+
|
7
|
+
* gdchart.c: Reformatted the code, added support for previously
|
8
|
+
omitted constants (e.g. GDC_NOVALUE), changed the names of some of
|
9
|
+
the attributes (from CamelCase to the standard ruby lower_case)
|
10
|
+
while providing aliases to maintain backwards compatibility.
|
11
|
+
|
12
|
+
2002-09-12 Takehiro Yonekura <ceramic@heart.104.net>
|
13
|
+
|
14
|
+
* pie_sample.rb: Change method names.
|
15
|
+
|
16
|
+
* gdchart.c: Fixed method name illegal mapping bug.
|
17
|
+
Method names are changed from '_3d_xxx' to 'xxx_3d' and from
|
18
|
+
'_0Shelf' to 'Shelf0'.
|
19
|
+
|
20
|
+
2002-09-05 Takehiro Yonekura <ceramic@heart.104.net>
|
21
|
+
|
22
|
+
* extconf.rb: Add library checks.
|
23
|
+
|
24
|
+
* gdchart.c: Fixed stack_type bug.
|
25
|
+
|
26
|
+
2002-08-05 Takehiro Yonekura <ceramic@heart.104.net>
|
27
|
+
|
28
|
+
* gdchart0.11.2dev/makefile: Fixed makefile. Now can compile if
|
29
|
+
you don't have libfreetype or libjpeg.
|
30
|
+
|
31
|
+
2002-08-05 Takehiro Yonekura <ceramic@heart.104.net>
|
32
|
+
|
33
|
+
* gdchart.c (gdc_pie_set_params): Fixed parameter name typo.
|
34
|
+
|
35
|
+
2002-08-05 Takehiro Yonekura <ceramic@heart.104.net>
|
36
|
+
|
37
|
+
* pie_sample.rb: Use v.0.11 functions.
|
38
|
+
|
39
|
+
* gdchart.c: GDChart 0.11.2dev was supported.
|
40
|
+
|
41
|
+
2002-07-30 Takehiro Yonekura <ceramic@heart.104.net>
|
42
|
+
|
43
|
+
* gdchart.c: GDC_xaxis_angle was supported.
|
44
|
+
|
45
|
+
2002-07-26 Takehiro Yonekura <ceramic@heart.104.net>
|
46
|
+
|
47
|
+
* gdchart.c: Function name changed. ('set_annotation' ->
|
48
|
+
'value_to_annotation_t')
|
49
|
+
(set_param): Modified ANNOTATION_T method.
|
50
|
+
|
51
|
+
2002-07-24 Takehiro Yonekura <ceramic@heart.104.net>
|
52
|
+
|
53
|
+
* gdchart0.11.2dev/makefile: Fixed gdchart's "BAD makefile" to be
|
54
|
+
able to compile using gmake.
|
55
|
+
|
56
|
+
* extconf.rb: Fixed make target.
|
57
|
+
|
58
|
+
* bar_sample.rb: Created.
|
59
|
+
|
60
|
+
* pie_sample.rb: Improve demo chart.
|
61
|
+
|
62
|
+
* gdchart.c (set_param): Fixed INT_ARRAY bug.
|
63
|
+
(Free_alloc_t): Fixed preprocessor misuse.
|
64
|
+
|
65
|
+
* extconf.rb: Modified to use gdchart0.11.2dev.
|
66
|
+
|
67
|
+
* Include gdchart0.11.2dev.
|
68
|
+
|
69
|
+
2002-07-22 Takehiro Yonekura <ceramic@heart.104.net>
|
70
|
+
|
71
|
+
* gdchart.c (gdc_set_params): Fixed parameter name typo.
|
72
|
+
|
73
|
+
2002-07-21 Takehiro Yonekura <ceramic@heart.104.net>
|
74
|
+
|
75
|
+
* gdchart.c: Fixed some bugs.
|
76
|
+
Rewrote variable convert (Ruby to C) functions.
|
77
|
+
|
78
|
+
2002-07-19 Takehiro Yonekura <ceramic@heart.104.net>
|
79
|
+
|
80
|
+
* gdchart.c: Ruby/GDChart can draw all chart now.
|
81
|
+
|
data/README
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
= Ruby/GDChart 1.0.0
|
2
|
+
|
3
|
+
This is an extension library designed by Arjen Laarhoven, Takehiro
|
4
|
+
Yonekura, and most recently Daniel Wislocki, to wrap the GDChart C library
|
5
|
+
written by Bruce Verderaime (http://www.fred.net/brv/chart/). Arjen
|
6
|
+
Laarhoven wrote the original version back in 2000, and Takehiro Yonekura
|
7
|
+
updated it in 2002. Compared to them, I've done relatively little other
|
8
|
+
than to turn the package into a gem, add a few missing (but extremely
|
9
|
+
important) constant definitions, and upgrade the GDChart library itself to
|
10
|
+
0.11.5dev. (Note: The C library that this gem wraps is included, but
|
11
|
+
requires the installation of gd-2.0.28 or higher.)
|
12
|
+
|
13
|
+
== A Brief Example
|
14
|
+
|
15
|
+
The following example creates a simple 200x200 PNG chart and writes it to
|
16
|
+
STDOUT:
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
require_gem 'ruby-gdchart'
|
20
|
+
|
21
|
+
GDChart.title = "A Chart"
|
22
|
+
GDChart.xtitle = "X-axis"
|
23
|
+
GDChart.ytitle = "Y-axis"
|
24
|
+
data = [1, 2, 3, 4, 5, 6]
|
25
|
+
# the wrong number of labels cause Ruby/GDChart to segfault!
|
26
|
+
labels = ["label 1", "label 2", "label 3", "label 4", "label 5", "label 6"]
|
27
|
+
numpoints = 6
|
28
|
+
numsets = 1
|
29
|
+
xsize = 200
|
30
|
+
ysize = 200
|
31
|
+
GDChart.out_graph(xsize, ysize, $stdout, GDChart::LINE, numpoints,
|
32
|
+
labels, numsets, data)
|
33
|
+
|
34
|
+
== Caveats
|
35
|
+
|
36
|
+
This library works, but there has been practically no testing.
|
37
|
+
Documentation is also extremely sparse (this goes for the original C
|
38
|
+
library as well), which I hope to rectify in the future. It's recommended
|
39
|
+
that you take a look at Bruce Verderaime's page
|
40
|
+
(http://www.fred.net/brv/chart/) to get a good sense of how the library
|
41
|
+
works, since the extension has an almost 1-1 mapping with the C library.
|
42
|
+
|
43
|
+
== License
|
44
|
+
|
45
|
+
This extension is distributed under the same terms as Ruby (see
|
46
|
+
<http://www.ruby-lang.org/en/LICENSE.txt>. The included gd-1.8.3 (needed by
|
47
|
+
GDCHART) and gdchart0.11.5dev libraries have their own license terms.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require_gem 'ruby-gdchart'
|
5
|
+
|
6
|
+
gdc = GDChart.new
|
7
|
+
|
8
|
+
gdc.title = "The prime"
|
9
|
+
gdc.title_size = GDChart::GIANT
|
10
|
+
gdc.ext_color = [ 0xFF3399, 0xFF9933, 0xFFEE33, 0x33FF33, 0x33FFCC, 0x9966FF ]
|
11
|
+
gdc.bg_color = 0xFFFFFF
|
12
|
+
|
13
|
+
data = [ 7, 11, 13, 17, 19, 23 ]
|
14
|
+
label = []
|
15
|
+
|
16
|
+
gdc.image_type = GDChart::JPEG
|
17
|
+
|
18
|
+
f = File.new "bar_sample.jpg", "w"
|
19
|
+
|
20
|
+
gdc.out_graph(300, 150, f, GDChart::BAR3D,
|
21
|
+
data.length, label, 1, data)
|
22
|
+
|
23
|
+
f.close
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_gem 'ruby-gdchart'
|
5
|
+
|
6
|
+
gdc = GDChart.new
|
7
|
+
|
8
|
+
gdc.title = "Title"
|
9
|
+
gdc.title_size = GDChart::GIANT
|
10
|
+
gdc.xtitle = "XTitle"
|
11
|
+
gdc.ytitle = "YTitle"
|
12
|
+
data = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]
|
13
|
+
|
14
|
+
gdc.set_color = [ 0xFF3399, 0xFF9933 ]
|
15
|
+
|
16
|
+
gdc.bg_color = 0xFFFFFF
|
17
|
+
|
18
|
+
# the wrong number of labels cause Ruby/gdc to segfault!
|
19
|
+
labels = ["label 1", "label 2", "label 3", "label 4", "label 5", "label 6"]
|
20
|
+
numpoints = 6
|
21
|
+
numsets = 2
|
22
|
+
xsize = 500
|
23
|
+
ysize = 300
|
24
|
+
gdc.image_type = GDChart::PNG
|
25
|
+
|
26
|
+
gdc.out_graph(xsize, ysize, $stdout, GDChart::LINE, numpoints,
|
27
|
+
labels, numsets, data)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_gem 'ruby-gdchart'
|
5
|
+
|
6
|
+
gdc = GDChartPie.new
|
7
|
+
|
8
|
+
gdc.color = [ 0xFF3399, 0xFF9933, 0xFFEE33, 0x33FF33, 0x33FFCC, 0x9966FF ]
|
9
|
+
gdc.bg_color = 0xFFFFFF
|
10
|
+
gdc.explode = [ 15, 0, 0, 0, 0, 0]
|
11
|
+
gdc.angle_3d = 180
|
12
|
+
gdc.depth_3d = 20
|
13
|
+
gdc.perspective = 50
|
14
|
+
gdc.image_type = GDChart::PNG
|
15
|
+
|
16
|
+
data = [1, 1, 1, 1, 1, 5]
|
17
|
+
label = ["hey", "gooble", "nah", "super-duper", "yes", "no"]
|
18
|
+
|
19
|
+
gdc.out_graph(500, 500, $stdout, GDChartPie::PIE3D, data.length, label, data)
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
GDCHART_DIR = "./gdchart0.11.5dev"
|
4
|
+
|
5
|
+
unless find_library("gd", "main")
|
6
|
+
puts("Can't find libgd")
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
unless have_header("gdchart.h")
|
11
|
+
$defs.push("-I#{GDCHART_DIR}")
|
12
|
+
puts("'-I#{GDCHART_DIR}' is defined.")
|
13
|
+
end
|
14
|
+
|
15
|
+
$defs.push("-DHAVE_LIBFREETYPE") if have_library("freetype")
|
16
|
+
$defs.push("-DHAVE_JPEG") if have_library("jpeg")
|
17
|
+
|
18
|
+
have_library("png")
|
19
|
+
have_library("z")
|
20
|
+
|
21
|
+
unless have_library("gdc", "main")
|
22
|
+
puts("Entering #{GDCHART_DIR}")
|
23
|
+
unless find_library("gdc", "main", GDCHART_DIR)
|
24
|
+
puts("Building GDCHART library in #{GDCHART_DIR}...")
|
25
|
+
if system("cd #{GDCHART_DIR}; make libgdc.a")
|
26
|
+
puts("done")
|
27
|
+
find_library("gdc", "main", GDCHART_DIR)
|
28
|
+
else
|
29
|
+
puts("compile error.")
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
create_makefile("GDChart")
|
data/ext/gdchart.c
ADDED
@@ -0,0 +1,1123 @@
|
|
1
|
+
/* //////////////////////////////////////////////////////////////////////////
|
2
|
+
|
3
|
+
* GDCHART.C - Created: Tue Nov 01 11:23:26 2005
|
4
|
+
|
5
|
+
* Copyright (C) 2000 Arjen Laarhoven <arjen@aragorn.demon.nl>
|
6
|
+
* Copyright (C) 2002 Takehiro Yonekura <ceramic@heart.104.net>
|
7
|
+
* Copyright (C) 2005 Daniel Wislocki <dada331@yahoo.com>
|
8
|
+
|
9
|
+
* Description: A Ruby extension module for Bruce Verderaime's GDCHART
|
10
|
+
charting library.
|
11
|
+
|
12
|
+
////////////////////////////////////////////////////////////////////////// */
|
13
|
+
|
14
|
+
/* I N C L U D E S /////////////////////////////////////////////////////// */
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
#include <string.h>
|
18
|
+
|
19
|
+
#include "gdc.h"
|
20
|
+
#include "gdchart.h"
|
21
|
+
#include "gdcpie.h"
|
22
|
+
|
23
|
+
#include "ruby.h"
|
24
|
+
#include "rubyio.h"
|
25
|
+
|
26
|
+
/* D E F I N E S ///////////////////////////////////////////////////////// */
|
27
|
+
|
28
|
+
#define TRUE 1
|
29
|
+
#define FALSE 0
|
30
|
+
|
31
|
+
/* If the pointer indicates allocated memory, free it. */
|
32
|
+
|
33
|
+
#define SAFE_FREE(t, v) if((t)->v != NULL) free((t)->v)
|
34
|
+
#define DEFINE_ATTR(o, n) rb_define_attr((o), (n), 1, 1)
|
35
|
+
#define DEFINE_ALIAS(o, n1, n2) { rb_define_alias((o), n1, n2); rb_define_alias((o), n1 "=", n2 "="); }
|
36
|
+
#define DEFINE_COMPAT(o, n1, n2) { DEFINE_ATTR(o, n2); DEFINE_ALIAS(o, n1, n2); }
|
37
|
+
|
38
|
+
/* G L O B A L S ///////////////////////////////////////////////////////// */
|
39
|
+
|
40
|
+
VALUE cGDChart;
|
41
|
+
VALUE cGDChartPie;
|
42
|
+
VALUE cGDChartAnnotation;
|
43
|
+
VALUE cGDChartScatter;
|
44
|
+
|
45
|
+
/*
|
46
|
+
* These structures are used by Ruby to do garbage collection.
|
47
|
+
* Pointers indicate dynamically allocated memory in class `GDChart' and
|
48
|
+
* 'GDChartPie'.
|
49
|
+
*/
|
50
|
+
|
51
|
+
typedef struct _gdc_t {
|
52
|
+
GDC_ANNOTATION_T *annotation;
|
53
|
+
GDC_SCATTER_T *scatter;
|
54
|
+
unsigned long *ExtVolColor;
|
55
|
+
unsigned long *SetColor;
|
56
|
+
unsigned long *ExtColor;
|
57
|
+
} gdc_t;
|
58
|
+
|
59
|
+
typedef struct _gdc_pie_t {
|
60
|
+
int *explode;
|
61
|
+
unsigned long *Color;
|
62
|
+
unsigned char *missing;
|
63
|
+
} gdc_pie_t;
|
64
|
+
|
65
|
+
/* F U N C T I O N S ///////////////////////////////////////////////////// */
|
66
|
+
|
67
|
+
static void gdc_free(gdc_t *t)
|
68
|
+
{
|
69
|
+
SAFE_FREE(t, annotation);
|
70
|
+
SAFE_FREE(t, scatter);
|
71
|
+
SAFE_FREE(t, ExtVolColor);
|
72
|
+
SAFE_FREE(t, SetColor);
|
73
|
+
SAFE_FREE(t, ExtColor);
|
74
|
+
free(t);
|
75
|
+
}
|
76
|
+
|
77
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
78
|
+
|
79
|
+
static void gdc_pie_free(gdc_pie_t *t)
|
80
|
+
{
|
81
|
+
SAFE_FREE(t, explode);
|
82
|
+
SAFE_FREE(t, Color);
|
83
|
+
SAFE_FREE(t, missing);
|
84
|
+
free(t);
|
85
|
+
}
|
86
|
+
|
87
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
88
|
+
|
89
|
+
/*
|
90
|
+
* GDC_ANNOTATION_T structure class definition
|
91
|
+
*/
|
92
|
+
static VALUE gdc_annotation_new(VALUE klass)
|
93
|
+
{
|
94
|
+
VALUE obj;
|
95
|
+
|
96
|
+
obj = rb_obj_alloc(klass);
|
97
|
+
return obj;
|
98
|
+
}
|
99
|
+
|
100
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
101
|
+
|
102
|
+
static VALUE gdc_annotation_init(VALUE obj)
|
103
|
+
{
|
104
|
+
rb_iv_set(obj, "@point", rb_float_new(0.0));
|
105
|
+
rb_iv_set(obj, "@color", INT2FIX(0));
|
106
|
+
rb_iv_set(obj, "@note", rb_str_new2(""));
|
107
|
+
return obj;
|
108
|
+
}
|
109
|
+
|
110
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
111
|
+
|
112
|
+
/*
|
113
|
+
* GDC_SCATTER_T structure class definition
|
114
|
+
*/
|
115
|
+
static VALUE gdc_scatter_new(VALUE klass)
|
116
|
+
{
|
117
|
+
VALUE obj;
|
118
|
+
|
119
|
+
obj = rb_obj_alloc(klass);
|
120
|
+
return obj;
|
121
|
+
}
|
122
|
+
|
123
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
124
|
+
|
125
|
+
static VALUE gdc_scatter_init(VALUE obj)
|
126
|
+
{
|
127
|
+
rb_iv_set(obj, "@point", rb_float_new(0.0));
|
128
|
+
rb_iv_set(obj, "@val", rb_float_new(0.0));
|
129
|
+
rb_iv_set(obj, "@width", INT2NUM(0));
|
130
|
+
rb_iv_set(obj, "@color", INT2NUM(0));
|
131
|
+
rb_iv_set(obj, "@ind", rb_const_get(obj, rb_intern("GDC_SCATTER_TRIANGLE_UP")));
|
132
|
+
return obj;
|
133
|
+
}
|
134
|
+
|
135
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
136
|
+
|
137
|
+
/*
|
138
|
+
*
|
139
|
+
* Data conversion functions
|
140
|
+
*
|
141
|
+
*/
|
142
|
+
|
143
|
+
/*
|
144
|
+
* Convert cGDChartAnnotation object to GDC_ANNOTATION_T structure.
|
145
|
+
* If argument type is illegal, returns 'FALSE'.
|
146
|
+
*/
|
147
|
+
static int value_to_annotation_t(VALUE value, GDC_ANNOTATION_T *an)
|
148
|
+
{
|
149
|
+
VALUE point, color, note, str;
|
150
|
+
char *s;
|
151
|
+
int s_len;
|
152
|
+
|
153
|
+
if(rb_obj_is_instance_of(value, cGDChartAnnotation) == Qfalse)
|
154
|
+
return FALSE;
|
155
|
+
|
156
|
+
point = rb_iv_get(value, "@point");
|
157
|
+
color = rb_iv_get(value, "@color");
|
158
|
+
note = rb_iv_get(value, "@note");
|
159
|
+
|
160
|
+
an->point = (float)NUM2DBL(point);
|
161
|
+
an->color = NUM2ULONG(color);
|
162
|
+
|
163
|
+
rb_check_safe_str(note);
|
164
|
+
str = StringValue(note);
|
165
|
+
s = RSTRING(str)->ptr;
|
166
|
+
s_len = RSTRING(str)->len;
|
167
|
+
if(s_len > MAX_NOTE_LEN)
|
168
|
+
rb_raise(rb_eArgError, "annotation note is too long");
|
169
|
+
if(s != NULL)
|
170
|
+
strncpy(an->note, s, s_len+1);
|
171
|
+
|
172
|
+
return TRUE;
|
173
|
+
}
|
174
|
+
|
175
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
176
|
+
|
177
|
+
/*
|
178
|
+
* Convert cGDChartScatter object to GDC_SCATTER_T structure.
|
179
|
+
* If argument type is illegal, returns 'FALSE'.
|
180
|
+
*/
|
181
|
+
static int value_to_scatter_t(VALUE value, GDC_SCATTER_T *sc)
|
182
|
+
{
|
183
|
+
VALUE point, val, width, color, ind;
|
184
|
+
|
185
|
+
if(rb_obj_is_instance_of(value, cGDChartScatter) == Qfalse)
|
186
|
+
return FALSE;
|
187
|
+
|
188
|
+
point = rb_iv_get(value, "@point");
|
189
|
+
val = rb_iv_get(value, "@val");
|
190
|
+
width = rb_iv_get(value, "@width");
|
191
|
+
color = rb_iv_get(value, "@color");
|
192
|
+
ind = rb_iv_get(value, "@ind");
|
193
|
+
|
194
|
+
sc->point = (float)NUM2DBL(point);
|
195
|
+
sc->val = (float)NUM2DBL(val);
|
196
|
+
sc->width = (unsigned short)NUM2UINT(width);
|
197
|
+
sc->color = NUM2ULONG(color);
|
198
|
+
sc->ind = (GDC_SCATTER_IND_T)NUM2INT(ind);
|
199
|
+
|
200
|
+
return TRUE;
|
201
|
+
}
|
202
|
+
|
203
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
204
|
+
|
205
|
+
/*
|
206
|
+
* C parameter types
|
207
|
+
*/
|
208
|
+
enum gdc_param_type {
|
209
|
+
BOOL,
|
210
|
+
BOOL_ARRAY,
|
211
|
+
CHAR,
|
212
|
+
UCHAR,
|
213
|
+
UCHAR_ARRAY,
|
214
|
+
INT,
|
215
|
+
INT_ARRAY,
|
216
|
+
SHORT,
|
217
|
+
USHORT,
|
218
|
+
ULONG,
|
219
|
+
ULONG_ARRAY,
|
220
|
+
FLOAT,
|
221
|
+
DOUBLE,
|
222
|
+
STRING,
|
223
|
+
FONT_SIZE,
|
224
|
+
STACK_T,
|
225
|
+
HLC_STYLE,
|
226
|
+
ANNOTATION_T,
|
227
|
+
SCATTER_T_ARRAY,
|
228
|
+
PCT_TYPE
|
229
|
+
};
|
230
|
+
|
231
|
+
/*
|
232
|
+
* Convert Ruby/GDChart parameters to C value.
|
233
|
+
* If instance variable is set, corresponding 'var' is initialized by the value
|
234
|
+
* and returns TRUE. If instance variable is not set, just returns FALSE.
|
235
|
+
*/
|
236
|
+
static int set_param(VALUE obj, const char *name, const void *var,
|
237
|
+
const enum gdc_param_type type)
|
238
|
+
{
|
239
|
+
VALUE value, entry;
|
240
|
+
void *result;
|
241
|
+
int i, length;
|
242
|
+
|
243
|
+
value = rb_iv_get(obj, name);
|
244
|
+
if(NIL_P(value))
|
245
|
+
return FALSE;
|
246
|
+
|
247
|
+
switch(type) {
|
248
|
+
case BOOL:
|
249
|
+
if(TYPE(value) != T_TRUE && TYPE(value) != T_FALSE)
|
250
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Bool");
|
251
|
+
|
252
|
+
*(char*)var = (char)value;
|
253
|
+
break;
|
254
|
+
|
255
|
+
case BOOL_ARRAY:
|
256
|
+
if(TYPE(value) != T_ARRAY)
|
257
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Bool Array");
|
258
|
+
|
259
|
+
length = RARRAY(value)->len;
|
260
|
+
result = ALLOC_N(char, length);
|
261
|
+
|
262
|
+
for(i = 0; i < length; i++) {
|
263
|
+
entry = rb_ary_entry(value, i);
|
264
|
+
if(TYPE(entry) != T_TRUE && TYPE(entry) != T_FALSE)
|
265
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Bool Array");
|
266
|
+
*((char*)result + i) = (char)entry;
|
267
|
+
}
|
268
|
+
*(char**)var = (char*)result;
|
269
|
+
break;
|
270
|
+
|
271
|
+
case CHAR:
|
272
|
+
if(TYPE(value) != T_FIXNUM)
|
273
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
274
|
+
|
275
|
+
*(char*)var = NUM2CHR(value);
|
276
|
+
break;
|
277
|
+
|
278
|
+
case UCHAR:
|
279
|
+
if(TYPE(value) != T_FIXNUM)
|
280
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
281
|
+
|
282
|
+
*(unsigned char*)var = (unsigned char)NUM2CHR(value);
|
283
|
+
break;
|
284
|
+
|
285
|
+
case INT:
|
286
|
+
if(TYPE(value) != T_FIXNUM)
|
287
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
288
|
+
|
289
|
+
*(int*)var = FIX2INT(value);
|
290
|
+
break;
|
291
|
+
|
292
|
+
case INT_ARRAY:
|
293
|
+
if(TYPE(value) != T_ARRAY)
|
294
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
|
295
|
+
|
296
|
+
length = RARRAY(value)->len;
|
297
|
+
result = ALLOC_N(int, length);
|
298
|
+
|
299
|
+
for(i = 0; i < length; i++) {
|
300
|
+
entry = rb_ary_entry(value, i);
|
301
|
+
if(TYPE(entry) != T_FIXNUM)
|
302
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
|
303
|
+
*((int*)result + i) = FIX2INT(entry);
|
304
|
+
}
|
305
|
+
*(int**)var = (int*)result;
|
306
|
+
break;
|
307
|
+
|
308
|
+
case SHORT:
|
309
|
+
if(TYPE(value) != T_FIXNUM)
|
310
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
311
|
+
|
312
|
+
*(short*)var = (short)FIX2INT(value);
|
313
|
+
break;
|
314
|
+
|
315
|
+
case USHORT:
|
316
|
+
if(TYPE(value) != T_FIXNUM)
|
317
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
318
|
+
|
319
|
+
*(unsigned short*)var = (unsigned short)FIX2UINT(value);
|
320
|
+
break;
|
321
|
+
|
322
|
+
case ULONG:
|
323
|
+
if(TYPE(value) != T_FIXNUM)
|
324
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
325
|
+
|
326
|
+
*(unsigned long*)var = FIX2ULONG(value);
|
327
|
+
break;
|
328
|
+
|
329
|
+
case ULONG_ARRAY:
|
330
|
+
if(TYPE(value) != T_ARRAY)
|
331
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
|
332
|
+
|
333
|
+
length = RARRAY(value)->len;
|
334
|
+
result = ALLOC_N(unsigned long, length);
|
335
|
+
|
336
|
+
for(i = 0; i < length; i++) {
|
337
|
+
entry = rb_ary_entry(value, i);
|
338
|
+
if(TYPE(entry) != T_FIXNUM)
|
339
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
|
340
|
+
*((unsigned long*)result + i) = FIX2ULONG(entry);
|
341
|
+
}
|
342
|
+
*(unsigned long**)var = (unsigned long*)result;
|
343
|
+
|
344
|
+
break;
|
345
|
+
|
346
|
+
case FLOAT:
|
347
|
+
if(TYPE(value) != T_FIXNUM && TYPE(value) != T_FLOAT)
|
348
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum or Float");
|
349
|
+
|
350
|
+
*(float*)var = (float)NUM2DBL(value);
|
351
|
+
break;
|
352
|
+
|
353
|
+
case DOUBLE:
|
354
|
+
if(TYPE(value) != T_FIXNUM && TYPE(value) != T_FLOAT)
|
355
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum or Float");
|
356
|
+
|
357
|
+
*(double*)var = NUM2DBL(value);
|
358
|
+
break;
|
359
|
+
|
360
|
+
case STRING:
|
361
|
+
if(TYPE(value) != T_STRING)
|
362
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "String");
|
363
|
+
|
364
|
+
rb_check_safe_str(value);
|
365
|
+
|
366
|
+
*(char**)var = StringValuePtr(value);
|
367
|
+
break;
|
368
|
+
|
369
|
+
case FONT_SIZE:
|
370
|
+
/* XXX: need more exact type check */
|
371
|
+
if(TYPE(value) != T_FIXNUM)
|
372
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
373
|
+
|
374
|
+
*(enum GDC_font_size *)var = (enum GDC_font_size)FIX2INT(value);
|
375
|
+
break;
|
376
|
+
|
377
|
+
case STACK_T:
|
378
|
+
/* XXX: need more exact type check */
|
379
|
+
if(TYPE(value) != T_FIXNUM)
|
380
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
381
|
+
|
382
|
+
*(GDC_STACK_T*)var = (GDC_STACK_T)FIX2INT(value);
|
383
|
+
break;
|
384
|
+
|
385
|
+
case HLC_STYLE:
|
386
|
+
/* XXX: need more exact type check */
|
387
|
+
if(TYPE(value) != T_FIXNUM)
|
388
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
389
|
+
|
390
|
+
*(GDC_HLC_STYLE_T*)var = (GDC_HLC_STYLE_T)FIX2INT(value);
|
391
|
+
break;
|
392
|
+
|
393
|
+
case ANNOTATION_T:
|
394
|
+
/* Because only 1 annotatin is allowd. */
|
395
|
+
result = ALLOC(GDC_ANNOTATION_T);
|
396
|
+
|
397
|
+
if(value_to_annotation_t(value, (GDC_ANNOTATION_T*)result) == FALSE) {
|
398
|
+
free(result);
|
399
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, rb_class2name(cGDChartAnnotation));
|
400
|
+
}
|
401
|
+
|
402
|
+
*(GDC_ANNOTATION_T**)var = (GDC_ANNOTATION_T*)result;
|
403
|
+
break;
|
404
|
+
|
405
|
+
case SCATTER_T_ARRAY:
|
406
|
+
if(TYPE(value) != T_ARRAY)
|
407
|
+
rb_raise(rb_eTypeError, "%s expect %s Array", name, rb_class2name(cGDChartScatter));
|
408
|
+
|
409
|
+
length = RARRAY(value)->len;
|
410
|
+
result = ALLOC_N(GDC_SCATTER_T, length);
|
411
|
+
|
412
|
+
for(i = 0; i < length; i++) {
|
413
|
+
entry = rb_ary_entry(value, i);
|
414
|
+
if(value_to_scatter_t(entry, (GDC_SCATTER_T*)(result+i)) == FALSE) {
|
415
|
+
free(result);
|
416
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
420
|
+
*(GDC_SCATTER_T**)var = (GDC_SCATTER_T*)result;
|
421
|
+
break;
|
422
|
+
|
423
|
+
case PCT_TYPE:
|
424
|
+
/* XXX: need more exact type check */
|
425
|
+
if(TYPE(value) != T_FIXNUM)
|
426
|
+
rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum");
|
427
|
+
|
428
|
+
*(GDCPIE_PCT_TYPE*)var = (GDCPIE_PCT_TYPE)FIX2INT(value);
|
429
|
+
break;
|
430
|
+
|
431
|
+
default:
|
432
|
+
rb_raise(rb_eTypeError, "type = %d", type);
|
433
|
+
break;
|
434
|
+
}
|
435
|
+
|
436
|
+
return TRUE;
|
437
|
+
}
|
438
|
+
|
439
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
440
|
+
|
441
|
+
/*
|
442
|
+
* GDChart class definition
|
443
|
+
*/
|
444
|
+
VALUE gdc_new(VALUE klass)
|
445
|
+
{
|
446
|
+
gdc_t *gdc;
|
447
|
+
VALUE obj;
|
448
|
+
|
449
|
+
obj = Data_Make_Struct(klass, struct _gdc_t, 0, gdc_free, gdc);
|
450
|
+
gdc->annotation = NULL;
|
451
|
+
gdc->scatter = NULL;
|
452
|
+
gdc->ExtVolColor = NULL;
|
453
|
+
gdc->SetColor = NULL;
|
454
|
+
gdc->ExtColor = NULL;
|
455
|
+
|
456
|
+
rb_obj_call_init(obj, 0, NULL);
|
457
|
+
|
458
|
+
return obj;
|
459
|
+
}
|
460
|
+
|
461
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
462
|
+
|
463
|
+
VALUE gdc_initialize(VALUE obj)
|
464
|
+
{
|
465
|
+
return obj;
|
466
|
+
}
|
467
|
+
|
468
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
469
|
+
|
470
|
+
/*
|
471
|
+
* Set GDChart option variable
|
472
|
+
*/
|
473
|
+
static VALUE gdc_set_params(VALUE obj)
|
474
|
+
{
|
475
|
+
gdc_t *gdc;
|
476
|
+
|
477
|
+
set_param(obj, "@ytitle", &GDC_ytitle, STRING);
|
478
|
+
set_param(obj, "@xtitle", &GDC_xtitle, STRING);
|
479
|
+
set_param(obj, "@ytitle2", &GDC_ytitle2, STRING);
|
480
|
+
set_param(obj, "@title", &GDC_title, STRING);
|
481
|
+
set_param(obj, "@title_size", &GDC_title_size, FONT_SIZE);
|
482
|
+
set_param(obj, "@ytitle_size", &GDC_ytitle_size, FONT_SIZE);
|
483
|
+
set_param(obj, "@xtitle_size", &GDC_xtitle_size, FONT_SIZE);
|
484
|
+
set_param(obj, "@yaxisfont_size", &GDC_yaxisfont_size, FONT_SIZE);
|
485
|
+
set_param(obj, "@xaxisfont_size", &GDC_xaxisfont_size, FONT_SIZE);
|
486
|
+
set_param(obj, "@xaxis_angle", &GDC_xaxis_angle, DOUBLE);
|
487
|
+
#ifdef HAVE_LIBFREETYPE
|
488
|
+
set_param(obj, "@title_font", &GDC_title_font, STRING);
|
489
|
+
set_param(obj, "@ytitle_font", &GDC_ytitle_font, STRING);
|
490
|
+
set_param(obj, "@xtitle_font", &GDC_xtitle_font, STRING);
|
491
|
+
set_param(obj, "@xaxis_font", &GDC_xaxis_font, STRING);
|
492
|
+
set_param(obj, "@yaxis_font", &GDC_yaxis_font, STRING);
|
493
|
+
set_param(obj, "@title_ptsize", &GDC_title_ptsize, DOUBLE);
|
494
|
+
set_param(obj, "@ytitle_ptsize", &GDC_ytitle_ptsize, DOUBLE);
|
495
|
+
set_param(obj, "@xtitle_ptsize", &GDC_xtitle_ptsize, DOUBLE);
|
496
|
+
set_param(obj, "@xaxis_ptsize", &GDC_xaxis_ptsize, DOUBLE);
|
497
|
+
set_param(obj, "@yaxis_ptsize", &GDC_yaxis_ptsize, DOUBLE);
|
498
|
+
#endif
|
499
|
+
set_param(obj, "@ylabel_fmt", &GDC_ylabel_fmt, STRING);
|
500
|
+
set_param(obj, "@ylabel2_fmt", &GDC_ylabel2_fmt, STRING);
|
501
|
+
set_param(obj, "@xlabel_ctl", &GDC_xlabel_ctl, BOOL_ARRAY);
|
502
|
+
set_param(obj, "@xlabel_spacing", &GDC_xlabel_spacing, SHORT);
|
503
|
+
set_param(obj, "@ylabel_density", &GDC_ylabel_density, CHAR);
|
504
|
+
set_param(obj, "@interpolations", &GDC_interpolations, BOOL);
|
505
|
+
set_param(obj, "@requested_ymin", &GDC_requested_ymin, FLOAT);
|
506
|
+
set_param(obj, "@requested_ymax", &GDC_requested_ymax, FLOAT);
|
507
|
+
set_param(obj, "@requested_yinterval", &GDC_requested_yinterval, FLOAT);
|
508
|
+
set_param(obj, "@shelf0", &GDC_0Shelf, BOOL);
|
509
|
+
set_param(obj, "@grid", &GDC_grid, BOOL);
|
510
|
+
set_param(obj, "@ticks", &GDC_ticks, INT);
|
511
|
+
set_param(obj, "@xaxis", &GDC_xaxis, BOOL);
|
512
|
+
set_param(obj, "@yaxis", &GDC_yaxis, BOOL);
|
513
|
+
set_param(obj, "@yaxis2", &GDC_yaxis2, BOOL);
|
514
|
+
set_param(obj, "@yval_style", &GDC_yval_style, BOOL);
|
515
|
+
set_param(obj, "@stack_type", &GDC_stack_type, STACK_T);
|
516
|
+
set_param(obj, "@depth_3d", &GDC_3d_depth, FLOAT);
|
517
|
+
set_param(obj, "@angle_3d", &GDC_3d_angle, UCHAR);
|
518
|
+
set_param(obj, "@bar_width", &GDC_bar_width, UCHAR);
|
519
|
+
set_param(obj, "@hlc_style", &GDC_HLC_style, HLC_STYLE);
|
520
|
+
set_param(obj, "@hlc_cap_width", &GDC_HLC_cap_width, UCHAR);
|
521
|
+
set_param(obj, "@annotation", &GDC_annotation, ANNOTATION_T);
|
522
|
+
set_param(obj, "@annotation_font_size", &GDC_annotation_font_size, FONT_SIZE);
|
523
|
+
#ifdef HAVE_LIBFREETYPE
|
524
|
+
set_param(obj, "@annotation_font", &GDC_annotation_font, FONT_SIZE);
|
525
|
+
set_param(obj, "@annotation_ptsize", &GDC_annotation_ptsize, DOUBLE);
|
526
|
+
#endif
|
527
|
+
set_param(obj, "@num_scatter_pts", &GDC_num_scatter_pts, INT);
|
528
|
+
set_param(obj, "@scatter", &GDC_scatter, SCATTER_T_ARRAY);
|
529
|
+
set_param(obj, "@thumbnail", &GDC_thumbnail, BOOL);
|
530
|
+
set_param(obj, "@thumblabel", &GDC_thumblabel, STRING);
|
531
|
+
set_param(obj, "@thumbval", &GDC_thumbval, FLOAT);
|
532
|
+
set_param(obj, "@border", &GDC_border, BOOL);
|
533
|
+
set_param(obj, "@bg_color", &GDC_BGColor, ULONG);
|
534
|
+
set_param(obj, "@grid_color", &GDC_GridColor, ULONG);
|
535
|
+
set_param(obj, "@line_color", &GDC_LineColor, ULONG);
|
536
|
+
set_param(obj, "@plot_color", &GDC_PlotColor, ULONG);
|
537
|
+
set_param(obj, "@vol_color", &GDC_VolColor, ULONG);
|
538
|
+
set_param(obj, "@title_color", &GDC_TitleColor, ULONG);
|
539
|
+
set_param(obj, "@xtitle_color", &GDC_XTitleColor, ULONG);
|
540
|
+
set_param(obj, "@ytitle_color", &GDC_YTitleColor, ULONG);
|
541
|
+
set_param(obj, "@ytitle2_color", &GDC_YTitle2Color, ULONG);
|
542
|
+
set_param(obj, "@xlabel_color", &GDC_XLabelColor, ULONG);
|
543
|
+
set_param(obj, "@ylabel_color", &GDC_YLabelColor, ULONG);
|
544
|
+
set_param(obj, "@ylabel2_color", &GDC_YLabel2Color, ULONG);
|
545
|
+
set_param(obj, "@ext_vol_color", &GDC_ExtVolColor, ULONG_ARRAY);
|
546
|
+
set_param(obj, "@set_color", &GDC_SetColor, ULONG_ARRAY);
|
547
|
+
set_param(obj, "@ext_color", &GDC_ExtColor, ULONG_ARRAY);
|
548
|
+
set_param(obj, "@transparent_bg", &GDC_transparent_bg, CHAR);
|
549
|
+
set_param(obj, "@bg_image", &GDC_BGImage, STRING);
|
550
|
+
|
551
|
+
set_param(obj, "@hard_size", &GDC_hard_size, BOOL);
|
552
|
+
set_param(obj, "@hard_xorig", &GDC_hard_xorig, INT);
|
553
|
+
set_param(obj, "@hard_graphwidth", &GDC_hard_graphwidth, INT);
|
554
|
+
set_param(obj, "@hard_yorig", &GDC_hard_yorig, INT);
|
555
|
+
set_param(obj, "@hard_grapheight", &GDC_hard_grapheight, INT);
|
556
|
+
|
557
|
+
set_param(obj, "@image_type", &GDC_image_type, INT);
|
558
|
+
|
559
|
+
|
560
|
+
Data_Get_Struct(obj, struct _gdc_t, gdc);
|
561
|
+
|
562
|
+
/*
|
563
|
+
* Before set new data, free allocated old data if it exist.
|
564
|
+
*/
|
565
|
+
SAFE_FREE(gdc, annotation);
|
566
|
+
SAFE_FREE(gdc, scatter);
|
567
|
+
SAFE_FREE(gdc, ExtVolColor);
|
568
|
+
SAFE_FREE(gdc, SetColor);
|
569
|
+
SAFE_FREE(gdc, ExtColor);
|
570
|
+
|
571
|
+
/*
|
572
|
+
* Copy pointers which indicate dynamically allocated structure.
|
573
|
+
* It is used to do GC by Ruby.
|
574
|
+
*
|
575
|
+
* ANNOTATION_T, SCATTER_T, ULONG_ARRAY parameters allocate memory
|
576
|
+
* dynamically.
|
577
|
+
*/
|
578
|
+
gdc->annotation = GDC_annotation;
|
579
|
+
gdc->scatter = GDC_scatter;
|
580
|
+
gdc->ExtVolColor = GDC_ExtVolColor;
|
581
|
+
gdc->SetColor = GDC_SetColor;
|
582
|
+
gdc->ExtColor = GDC_ExtColor;
|
583
|
+
|
584
|
+
return obj;
|
585
|
+
}
|
586
|
+
|
587
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
588
|
+
|
589
|
+
/*
|
590
|
+
* GDChartPie class definition
|
591
|
+
*/
|
592
|
+
VALUE gdc_pie_new(VALUE klass)
|
593
|
+
{
|
594
|
+
gdc_pie_t *gdc_pie;
|
595
|
+
VALUE obj;
|
596
|
+
|
597
|
+
obj = Data_Make_Struct(klass, struct _gdc_pie_t, 0, gdc_pie_free, gdc_pie);
|
598
|
+
gdc_pie->explode = NULL;
|
599
|
+
gdc_pie->Color = NULL;
|
600
|
+
gdc_pie->missing = NULL;
|
601
|
+
|
602
|
+
rb_obj_call_init(obj, 0, NULL);
|
603
|
+
|
604
|
+
return obj;
|
605
|
+
}
|
606
|
+
|
607
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
608
|
+
|
609
|
+
VALUE gdc_pie_initialize(VALUE obj)
|
610
|
+
{
|
611
|
+
return obj;
|
612
|
+
}
|
613
|
+
|
614
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
615
|
+
|
616
|
+
/*
|
617
|
+
* Set GDChart option variable
|
618
|
+
*/
|
619
|
+
static VALUE gdc_pie_set_params(VALUE obj)
|
620
|
+
{
|
621
|
+
gdc_pie_t *gdc_pie;
|
622
|
+
|
623
|
+
set_param(obj, "@bg_color", &GDCPIE_BGColor, ULONG);
|
624
|
+
set_param(obj, "@plot_color", &GDCPIE_PlotColor, ULONG);
|
625
|
+
set_param(obj, "@line_color", &GDCPIE_LineColor, ULONG);
|
626
|
+
set_param(obj, "@edge_color", &GDCPIE_EdgeColor, ULONG);
|
627
|
+
set_param(obj, "@other_threshold", &GDCPIE_other_threshold, CHAR);
|
628
|
+
set_param(obj, "@angle_3d", &GDCPIE_3d_angle, USHORT);
|
629
|
+
set_param(obj, "@depth_3d", &GDCPIE_3d_depth, USHORT);
|
630
|
+
set_param(obj, "@perspective", &GDCPIE_perspective, USHORT);
|
631
|
+
set_param(obj, "@title", &GDCPIE_title, STRING);
|
632
|
+
set_param(obj, "@title_size", &GDCPIE_title_size, FONT_SIZE);
|
633
|
+
set_param(obj, "@label_size", &GDCPIE_label_size, FONT_SIZE);
|
634
|
+
#ifdef HAVE_LIBFREETYPE
|
635
|
+
set_param(obj, "@title_font", &GDCPIE_title_font, STRING);
|
636
|
+
set_param(obj, "@label_font", &GDCPIE_label_font, STRING);
|
637
|
+
set_param(obj, "@title_ptsize", &GDCPIE_title_ptsize, DOUBLE);
|
638
|
+
set_param(obj, "@label_ptsize", &GDCPIE_label_ptsize, DOUBLE);
|
639
|
+
#endif
|
640
|
+
set_param(obj, "@label_dist", &GDCPIE_label_dist, INT);
|
641
|
+
set_param(obj, "@label_line", &GDCPIE_label_line, BOOL);
|
642
|
+
set_param(obj, "@explode", &GDCPIE_explode, INT_ARRAY);
|
643
|
+
set_param(obj, "@color", &GDCPIE_Color, ULONG_ARRAY);
|
644
|
+
set_param(obj, "@missing", &GDCPIE_missing, BOOL_ARRAY);
|
645
|
+
set_param(obj, "@percent_labels", &GDCPIE_percent_labels, PCT_TYPE);
|
646
|
+
set_param(obj, "@percent_fmt", &GDCPIE_percent_fmt, STRING);
|
647
|
+
|
648
|
+
set_param(obj, "@image_type", &GDC_image_type, INT);
|
649
|
+
|
650
|
+
Data_Get_Struct(obj, struct _gdc_pie_t, gdc_pie);
|
651
|
+
|
652
|
+
/*
|
653
|
+
* Before set new data, free allocated old data if it exist.
|
654
|
+
*/
|
655
|
+
SAFE_FREE(gdc_pie, explode);
|
656
|
+
SAFE_FREE(gdc_pie, Color);
|
657
|
+
SAFE_FREE(gdc_pie, missing);
|
658
|
+
|
659
|
+
/*
|
660
|
+
* Copy pointers which indicate dynamically allocated structure.
|
661
|
+
* It is used to do GC by Ruby.
|
662
|
+
*
|
663
|
+
* INT_ARRAY, ULONG_ARRAY, UCHAR_ARRAY parameters allocate memory
|
664
|
+
* dynamically.
|
665
|
+
*/
|
666
|
+
gdc_pie->explode = GDCPIE_explode;
|
667
|
+
gdc_pie->Color = GDCPIE_Color;
|
668
|
+
gdc_pie->missing = GDCPIE_missing;
|
669
|
+
|
670
|
+
return obj;
|
671
|
+
}
|
672
|
+
|
673
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
674
|
+
|
675
|
+
/*
|
676
|
+
* output graph image
|
677
|
+
*/
|
678
|
+
static VALUE gdc_out_graph(int argc, VALUE *argv, VALUE self)
|
679
|
+
{
|
680
|
+
VALUE imgwidth, imgheight; /* output image size */
|
681
|
+
VALUE out; /* output file descriptor */
|
682
|
+
VALUE type; /* chart type */
|
683
|
+
VALUE num_points; /* x axis points */
|
684
|
+
VALUE labels;
|
685
|
+
VALUE num_sets; /* number of data sets */
|
686
|
+
VALUE data;
|
687
|
+
VALUE combodata;
|
688
|
+
|
689
|
+
OpenFile *fptr;
|
690
|
+
FILE *f;
|
691
|
+
|
692
|
+
int i;
|
693
|
+
int label_num;
|
694
|
+
int all_points;
|
695
|
+
char **c_labels;
|
696
|
+
float *fdata, *fcombodata;
|
697
|
+
|
698
|
+
rb_scan_args(argc, argv, "81", &imgwidth, &imgheight,
|
699
|
+
&out, &type, &num_points, &labels, &num_sets,
|
700
|
+
&data, &combodata);
|
701
|
+
|
702
|
+
/* Do type check */
|
703
|
+
Check_Type(imgwidth, T_FIXNUM);
|
704
|
+
Check_Type(imgheight, T_FIXNUM);
|
705
|
+
Check_Type(out, T_FILE);
|
706
|
+
Check_Type(type, T_FIXNUM); /* XXX: 'type' is constant? */
|
707
|
+
Check_Type(num_points, T_FIXNUM);
|
708
|
+
Check_Type(labels, T_ARRAY);
|
709
|
+
Check_Type(num_sets, T_FIXNUM);
|
710
|
+
Check_Type(data, T_ARRAY);
|
711
|
+
if(combodata != Qnil)
|
712
|
+
Check_Type(combodata, T_ARRAY);
|
713
|
+
|
714
|
+
/* Set GDChart options */
|
715
|
+
gdc_set_params(self);
|
716
|
+
|
717
|
+
/* prepare output */
|
718
|
+
rb_io_binmode(out);
|
719
|
+
GetOpenFile(out, fptr);
|
720
|
+
rb_io_check_writable(fptr);
|
721
|
+
f = GetWriteFile(fptr);
|
722
|
+
|
723
|
+
label_num = RARRAY(labels)->len;
|
724
|
+
if(label_num < NUM2INT(num_points))
|
725
|
+
label_num = NUM2INT(num_points);
|
726
|
+
|
727
|
+
c_labels = ALLOC_N(char *, label_num);
|
728
|
+
for(i = 0; i < label_num; i++) {
|
729
|
+
switch(TYPE(rb_ary_entry(labels, i))) {
|
730
|
+
case T_NIL:
|
731
|
+
c_labels[i] = "";
|
732
|
+
break;
|
733
|
+
|
734
|
+
case T_STRING:
|
735
|
+
c_labels[i] = STR2CSTR(rb_ary_entry(labels, i));
|
736
|
+
break;
|
737
|
+
|
738
|
+
default:
|
739
|
+
rb_raise(rb_eTypeError, "type error");
|
740
|
+
break;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
all_points = FIX2INT(num_points) * FIX2INT(num_sets);
|
745
|
+
fdata = ALLOC_N(float, all_points);
|
746
|
+
for(i = 0; i < all_points; i++)
|
747
|
+
fdata[i] = NUM2DBL(rb_ary_entry(data, i));
|
748
|
+
|
749
|
+
|
750
|
+
if(combodata == Qnil)
|
751
|
+
fcombodata = NULL;
|
752
|
+
else {
|
753
|
+
fcombodata = ALLOC_N(float, FIX2INT(num_points));
|
754
|
+
for(i = 0; i < FIX2INT(num_points); i++)
|
755
|
+
fcombodata[i] = NUM2DBL(rb_ary_entry(combodata, i));
|
756
|
+
|
757
|
+
}
|
758
|
+
|
759
|
+
#ifdef DEBUG
|
760
|
+
for(i = 0; i < FIX2INT(num_points) * FIX2INT(num_sets); i++)
|
761
|
+
rb_warn("fdata[%d] = %f", i, fdata[i]);
|
762
|
+
|
763
|
+
rb_warn("Going to call GDC_out_graph...");
|
764
|
+
rb_warn("Arguments to GDC_outgraph:");
|
765
|
+
rb_warn("%d, %d, %x, %d, %d, %p, %d, %p, %p",FIX2INT(imgwidth),
|
766
|
+
FIX2INT(imgheight),
|
767
|
+
f,
|
768
|
+
FIX2INT(type),
|
769
|
+
FIX2INT(num_points),
|
770
|
+
clabels,
|
771
|
+
FIX2INT(num_sets),
|
772
|
+
fdata,
|
773
|
+
0
|
774
|
+
);
|
775
|
+
#endif
|
776
|
+
|
777
|
+
GDC_out_graph(FIX2INT(imgwidth),
|
778
|
+
FIX2INT(imgheight),
|
779
|
+
f,
|
780
|
+
FIX2INT(type),
|
781
|
+
FIX2INT(num_points),
|
782
|
+
c_labels,
|
783
|
+
FIX2INT(num_sets),
|
784
|
+
fdata,
|
785
|
+
fcombodata
|
786
|
+
);
|
787
|
+
|
788
|
+
if(c_labels != NULL) free(c_labels);
|
789
|
+
if(fdata != NULL) free(fdata);
|
790
|
+
if(fcombodata != NULL) free(fcombodata);
|
791
|
+
|
792
|
+
return Qnil;
|
793
|
+
}
|
794
|
+
|
795
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
796
|
+
|
797
|
+
static VALUE gdc_pie_out_graph(int argc, VALUE *argv, VALUE self)
|
798
|
+
{
|
799
|
+
VALUE imgwidth, imgheight; /* output image size */
|
800
|
+
VALUE out; /* output file descriptor */
|
801
|
+
VALUE type; /* chart type */
|
802
|
+
VALUE num_points; /* x axis points */
|
803
|
+
VALUE labels;
|
804
|
+
VALUE data;
|
805
|
+
|
806
|
+
OpenFile *fptr;
|
807
|
+
FILE *f;
|
808
|
+
|
809
|
+
int i;
|
810
|
+
int label_num;
|
811
|
+
char **c_labels;
|
812
|
+
float *fdata;
|
813
|
+
|
814
|
+
rb_scan_args(argc, argv, "7", &imgwidth, &imgheight,
|
815
|
+
&out, &type, &num_points, &labels, &data);
|
816
|
+
|
817
|
+
/* Do some sanity check */
|
818
|
+
Check_Type(imgwidth, T_FIXNUM);
|
819
|
+
Check_Type(imgheight, T_FIXNUM);
|
820
|
+
Check_Type(out, T_FILE);
|
821
|
+
Check_Type(type, T_FIXNUM); /* XXX: 'type' is constant? */
|
822
|
+
Check_Type(num_points, T_FIXNUM);
|
823
|
+
Check_Type(labels, T_ARRAY);
|
824
|
+
Check_Type(data, T_ARRAY);
|
825
|
+
|
826
|
+
/* Set GDChart options */
|
827
|
+
gdc_pie_set_params(self);
|
828
|
+
|
829
|
+
/* prepare output */
|
830
|
+
rb_io_binmode(out);
|
831
|
+
GetOpenFile(out, fptr);
|
832
|
+
rb_io_check_writable(fptr);
|
833
|
+
f = GetWriteFile(fptr);
|
834
|
+
|
835
|
+
label_num = RARRAY(labels)->len;
|
836
|
+
if(label_num < NUM2INT(num_points))
|
837
|
+
label_num = NUM2INT(num_points);
|
838
|
+
|
839
|
+
c_labels = ALLOC_N(char *, label_num);
|
840
|
+
for(i = 0; i < label_num; i++) {
|
841
|
+
switch(TYPE(rb_ary_entry(labels, i))) {
|
842
|
+
case T_NIL:
|
843
|
+
c_labels[i] = "";
|
844
|
+
break;
|
845
|
+
|
846
|
+
case T_STRING:
|
847
|
+
c_labels[i] = STR2CSTR(rb_ary_entry(labels, i));
|
848
|
+
break;
|
849
|
+
|
850
|
+
default:
|
851
|
+
rb_raise(rb_eTypeError, "type error");
|
852
|
+
break;
|
853
|
+
}
|
854
|
+
}
|
855
|
+
|
856
|
+
fdata = ALLOC_N(float, FIX2INT(num_points));
|
857
|
+
for(i = 0; i < FIX2INT(num_points); i++)
|
858
|
+
fdata[i] = NUM2DBL(rb_ary_entry(data, i));
|
859
|
+
|
860
|
+
GDC_out_pie(FIX2INT(imgwidth),
|
861
|
+
FIX2INT(imgheight),
|
862
|
+
f,
|
863
|
+
FIX2INT(type),
|
864
|
+
FIX2INT(num_points),
|
865
|
+
c_labels,
|
866
|
+
fdata
|
867
|
+
);
|
868
|
+
|
869
|
+
if(c_labels != NULL) free(c_labels);
|
870
|
+
if(fdata != NULL) free(fdata);
|
871
|
+
|
872
|
+
return Qnil;
|
873
|
+
}
|
874
|
+
|
875
|
+
/* /////////////////////////////////////////////////////////////////////// */
|
876
|
+
|
877
|
+
void Init_GDChart(void)
|
878
|
+
{
|
879
|
+
cGDChart = rb_define_class("GDChart", rb_cObject);
|
880
|
+
cGDChartPie = rb_define_class("GDChartPie", rb_cObject);
|
881
|
+
cGDChartAnnotation = rb_define_class_under(cGDChart, "Annotation", rb_cObject);
|
882
|
+
cGDChartScatter = rb_define_class_under(cGDChart, "Scatter", rb_cObject);
|
883
|
+
|
884
|
+
/* Chart types */
|
885
|
+
rb_define_const(cGDChart, "LINE", INT2FIX(GDC_LINE));
|
886
|
+
rb_define_const(cGDChart, "AREA", INT2FIX(GDC_AREA));
|
887
|
+
rb_define_const(cGDChart, "BAR", INT2FIX(GDC_BAR));
|
888
|
+
rb_define_const(cGDChart, "FLOATINGBAR", INT2FIX(GDC_FLOATINGBAR));
|
889
|
+
rb_define_const(cGDChart, "HILOCLOSE", INT2FIX(GDC_HILOCLOSE));
|
890
|
+
rb_define_const(cGDChart, "COMBO_LINE_BAR", INT2FIX(GDC_COMBO_LINE_BAR));
|
891
|
+
rb_define_const(cGDChart, "COMBO_HLC_BAR", INT2FIX(GDC_COMBO_HLC_BAR));
|
892
|
+
rb_define_const(cGDChart, "COMBO_LINE_AREA", INT2FIX(GDC_COMBO_LINE_AREA));
|
893
|
+
rb_define_const(cGDChart, "COMBO_LINE_LINE", INT2FIX(GDC_COMBO_LINE_LINE));
|
894
|
+
rb_define_const(cGDChart, "COMBO_HLC_AREA", INT2FIX(GDC_COMBO_HLC_AREA));
|
895
|
+
rb_define_const(cGDChart, "HILOCLOSE3D", INT2FIX(GDC_3DHILOCLOSE));
|
896
|
+
rb_define_const(cGDChart, "COMBO_LINE_BAR3D", INT2FIX(GDC_3DCOMBO_LINE_BAR));
|
897
|
+
rb_define_const(cGDChart, "COMBO_LINE_AREA3D", INT2FIX(GDC_3DCOMBO_LINE_AREA));
|
898
|
+
rb_define_const(cGDChart, "COMBO_LINE_LINE3D", INT2FIX(GDC_3DCOMBO_LINE_LINE));
|
899
|
+
rb_define_const(cGDChart, "COMBO_HLC_BAR3D", INT2FIX(GDC_3DCOMBO_HLC_BAR));
|
900
|
+
rb_define_const(cGDChart, "COMBO_HLC_AREA3D", INT2FIX(GDC_3DCOMBO_HLC_AREA));
|
901
|
+
rb_define_const(cGDChart, "BAR3D", INT2FIX(GDC_3DBAR));
|
902
|
+
rb_define_const(cGDChart, "FLOATINGBAR3D", INT2FIX(GDC_3DFLOATINGBAR));
|
903
|
+
rb_define_const(cGDChart, "AREA3D", INT2FIX(GDC_3DAREA));
|
904
|
+
rb_define_const(cGDChart, "LINE3D", INT2FIX(GDC_3DLINE));
|
905
|
+
|
906
|
+
/* Stack types */
|
907
|
+
rb_define_const(cGDChart, "STACK_DEPTH", INT2FIX(GDC_STACK_DEPTH));
|
908
|
+
rb_define_const(cGDChart, "STACK_SUM", INT2FIX(GDC_STACK_SUM));
|
909
|
+
rb_define_const(cGDChart, "STACK_BESIDE", INT2FIX(GDC_STACK_BESIDE));
|
910
|
+
rb_define_const(cGDChart, "STACK_LAYER", INT2FIX(GDC_STACK_LAYER));
|
911
|
+
|
912
|
+
/* HiLoClose chart styles */
|
913
|
+
rb_define_const(cGDChart, "HLC_DIAMOND", INT2FIX(GDC_HLC_DIAMOND));
|
914
|
+
rb_define_const(cGDChart, "HLC_CLOSE_CONNECTED", INT2FIX(GDC_HLC_CLOSE_CONNECTED));
|
915
|
+
rb_define_const(cGDChart, "HLC_CONNECTING", INT2FIX(GDC_HLC_CONNECTING));
|
916
|
+
rb_define_const(cGDChart, "HLC_I_CAP", INT2FIX(GDC_HLC_I_CAP));
|
917
|
+
|
918
|
+
/* Axis tick types */
|
919
|
+
rb_define_const(cGDChart, "TICK_LABELS", INT2FIX(GDC_TICK_LABELS));
|
920
|
+
rb_define_const(cGDChart, "TICK_POINTS", INT2FIX(GDC_TICK_POINTS));
|
921
|
+
rb_define_const(cGDChart, "TICK_NONE", INT2FIX(GDC_TICK_NONE));
|
922
|
+
|
923
|
+
/* Border types */
|
924
|
+
rb_define_const(cGDChart, "BORDER_NONE", INT2FIX(GDC_BORDER_NONE));
|
925
|
+
rb_define_const(cGDChart, "BORDER_ALL", INT2FIX(GDC_BORDER_ALL));
|
926
|
+
rb_define_const(cGDChart, "BORDER_X", INT2FIX(GDC_BORDER_X));
|
927
|
+
rb_define_const(cGDChart, "BORDER_Y", INT2FIX(GDC_BORDER_Y));
|
928
|
+
rb_define_const(cGDChart, "BORDER_Y2", INT2FIX(GDC_BORDER_Y2));
|
929
|
+
rb_define_const(cGDChart, "BORDER_TOP", INT2FIX(GDC_BORDER_TOP));
|
930
|
+
|
931
|
+
/* Output types */
|
932
|
+
rb_define_const(cGDChart, "GIF", INT2FIX(GDC_GIF));
|
933
|
+
rb_define_const(cGDChart, "JPEG", INT2FIX(GDC_JPEG));
|
934
|
+
rb_define_const(cGDChart, "PNG", INT2FIX(GDC_PNG));
|
935
|
+
rb_define_const(cGDChart, "WBMP", INT2FIX(GDC_WBMP));
|
936
|
+
|
937
|
+
/* Font sizes */
|
938
|
+
rb_define_const(cGDChart, "TINY", INT2FIX(GDC_TINY));
|
939
|
+
rb_define_const(cGDChart, "SMALL", INT2FIX(GDC_SMALL));
|
940
|
+
rb_define_const(cGDChart, "MEDBOLD", INT2FIX(GDC_MEDBOLD));
|
941
|
+
rb_define_const(cGDChart, "LARGE", INT2FIX(GDC_LARGE));
|
942
|
+
rb_define_const(cGDChart, "GIANT", INT2FIX(GDC_GIANT));
|
943
|
+
|
944
|
+
#if 0
|
945
|
+
/* Text justifications */
|
946
|
+
rb_define_const(cGDChart, "JUSTIFY_RIGHT", INT2FIX(GDC_JUSTIFY_RIGHT));
|
947
|
+
rb_define_const(cGDChart, "JUSTIFY_CENTER", INT2FIX(GDC_JUSTIFY_CENTER));
|
948
|
+
rb_define_const(cGDChart, "JUSTIFY_LEFT", INT2FIX(GDC_JUSTIFY_LEFT));
|
949
|
+
#endif
|
950
|
+
rb_define_const(cGDChart, "INTERP_VALUE", rb_float_new(GDC_INTERP_VALUE));
|
951
|
+
rb_define_const(cGDChart, "NOVALUE", rb_float_new(GDC_NOVALUE));
|
952
|
+
rb_define_const(cGDChart, "NOCOLOR", INT2FIX(GDC_NOCOLOR));
|
953
|
+
rb_define_const(cGDChart, "DFLTCOLOR", INT2FIX(GDC_DFLTCOLOR));
|
954
|
+
|
955
|
+
/* method definitions */
|
956
|
+
rb_define_singleton_method(cGDChart, "new", gdc_new, 0);
|
957
|
+
rb_define_method(cGDChart, "initialize", gdc_initialize, 0);
|
958
|
+
rb_define_method(cGDChart, "set_param", gdc_set_params, 0);
|
959
|
+
|
960
|
+
rb_define_method(cGDChart, "out_graph", gdc_out_graph, -1);
|
961
|
+
|
962
|
+
rb_define_attr(cGDChart, "ytitle", 1, 1);
|
963
|
+
rb_define_attr(cGDChart, "xtitle", 1, 1);
|
964
|
+
rb_define_attr(cGDChart, "ytitle2", 1, 1);
|
965
|
+
rb_define_attr(cGDChart, "title", 1, 1);
|
966
|
+
rb_define_attr(cGDChart, "title_size", 1, 1);
|
967
|
+
rb_define_attr(cGDChart, "ytitle_size", 1, 1);
|
968
|
+
rb_define_attr(cGDChart, "xtitle_size", 1, 1);
|
969
|
+
rb_define_attr(cGDChart, "yaxisfont_size", 1, 1);
|
970
|
+
rb_define_attr(cGDChart, "xaxisfont_size", 1, 1);
|
971
|
+
rb_define_attr(cGDChart, "xaxis_angle", 1, 1);
|
972
|
+
#ifdef HAVE_LIBFREETYPE
|
973
|
+
rb_define_attr(cGDChart, "title_font", 1, 1);
|
974
|
+
rb_define_attr(cGDChart, "ytitle_font", 1, 1);
|
975
|
+
rb_define_attr(cGDChart, "xtitle_font", 1, 1);
|
976
|
+
rb_define_attr(cGDChart, "xaxis_font", 1, 1);
|
977
|
+
rb_define_attr(cGDChart, "yaxis_font", 1, 1);
|
978
|
+
rb_define_attr(cGDChart, "title_ptsize", 1, 1);
|
979
|
+
rb_define_attr(cGDChart, "ytitle_ptsize", 1, 1);
|
980
|
+
rb_define_attr(cGDChart, "xtitle_ptsize", 1, 1);
|
981
|
+
rb_define_attr(cGDChart, "xaxis_ptsize", 1, 1);
|
982
|
+
rb_define_attr(cGDChart, "yaxis_ptsize", 1, 1);
|
983
|
+
#endif
|
984
|
+
rb_define_attr(cGDChart, "ylabel_fmt", 1, 1);
|
985
|
+
rb_define_attr(cGDChart, "ylabel2_fmt", 1, 1);
|
986
|
+
rb_define_attr(cGDChart, "xlabel_ctl", 1, 1);
|
987
|
+
rb_define_attr(cGDChart, "xlabel_spacing", 1, 1);
|
988
|
+
rb_define_attr(cGDChart, "ylabel_density", 1, 1);
|
989
|
+
rb_define_attr(cGDChart, "interpolations", 1, 1);
|
990
|
+
rb_define_attr(cGDChart, "requested_ymin", 1, 1);
|
991
|
+
rb_define_attr(cGDChart, "requested_ymax", 1, 1);
|
992
|
+
rb_define_attr(cGDChart, "requested_yinterval", 1, 1);
|
993
|
+
DEFINE_COMPAT(cGDChart, "Shelf0", "shelf0");
|
994
|
+
rb_define_attr(cGDChart, "grid", 1, 1);
|
995
|
+
rb_define_attr(cGDChart, "ticks", 1, 1);
|
996
|
+
rb_define_attr(cGDChart, "xaxis", 1, 1);
|
997
|
+
rb_define_attr(cGDChart, "yaxis", 1, 1);
|
998
|
+
rb_define_attr(cGDChart, "yaxis2", 1, 1);
|
999
|
+
rb_define_attr(cGDChart, "yval_style", 1, 1);
|
1000
|
+
rb_define_attr(cGDChart, "stack_type", 1, 1);
|
1001
|
+
rb_define_attr(cGDChart, "depth_3d", 1, 1);
|
1002
|
+
rb_define_attr(cGDChart, "angle_3d", 1, 1);
|
1003
|
+
rb_define_attr(cGDChart, "bar_width", 1, 1);
|
1004
|
+
DEFINE_COMPAT(cGDChart, "HLC_style", "hlc_style");
|
1005
|
+
DEFINE_COMPAT(cGDChart, "HLC_cap_width", "hlc_cap_width");
|
1006
|
+
rb_define_attr(cGDChart, "annotation", 1, 1);
|
1007
|
+
rb_define_attr(cGDChart, "annotation_font_size", 1, 1);
|
1008
|
+
#ifdef HAVE_LIBFREETYPE
|
1009
|
+
rb_define_attr(cGDChart, "annotation_font", 1, 1);
|
1010
|
+
rb_define_attr(cGDChart, "annotation_ptsize", 1, 1);
|
1011
|
+
#endif
|
1012
|
+
rb_define_attr(cGDChart, "num_scatter_pts", 1, 1);
|
1013
|
+
rb_define_attr(cGDChart, "scatter", 1, 1);
|
1014
|
+
rb_define_attr(cGDChart, "thumbnail", 1, 1);
|
1015
|
+
rb_define_attr(cGDChart, "thumblabel", 1, 1);
|
1016
|
+
rb_define_attr(cGDChart, "thumbval", 1, 1);
|
1017
|
+
rb_define_attr(cGDChart, "border", 1, 1);
|
1018
|
+
rb_define_attr(cGDChart, "transparent_bg", 1, 1);
|
1019
|
+
|
1020
|
+
DEFINE_COMPAT(cGDChart, "SetColor", "set_color");
|
1021
|
+
DEFINE_COMPAT(cGDChart, "BGColor", "bg_color");
|
1022
|
+
DEFINE_COMPAT(cGDChart, "GridColor", "grid_color");
|
1023
|
+
DEFINE_COMPAT(cGDChart, "LineColor", "line_color");
|
1024
|
+
DEFINE_COMPAT(cGDChart, "PlotColor", "plot_color");
|
1025
|
+
DEFINE_COMPAT(cGDChart, "VolColor", "vol_color");
|
1026
|
+
DEFINE_COMPAT(cGDChart, "TitleColor", "title_color");
|
1027
|
+
DEFINE_COMPAT(cGDChart, "XTitleColor", "xtitle_color");
|
1028
|
+
DEFINE_COMPAT(cGDChart, "YTitleColor", "ytitle_color");
|
1029
|
+
DEFINE_COMPAT(cGDChart, "YTitle2Color", "ytitle2_color");
|
1030
|
+
DEFINE_COMPAT(cGDChart, "XLabelColor", "xlabel_color");
|
1031
|
+
DEFINE_COMPAT(cGDChart, "YLabelColor", "ylabel_color");
|
1032
|
+
DEFINE_COMPAT(cGDChart, "YLabel2Color", "ylabel2_color");
|
1033
|
+
DEFINE_COMPAT(cGDChart, "ExtVolColor", "ext_vol_color");
|
1034
|
+
DEFINE_COMPAT(cGDChart, "ExtColor", "ext_color");
|
1035
|
+
DEFINE_COMPAT(cGDChart, "BGImage", "bg_image");
|
1036
|
+
|
1037
|
+
rb_define_attr(cGDChart, "hard_size", 1, 1);
|
1038
|
+
rb_define_attr(cGDChart, "hard_xorig", 1, 1);
|
1039
|
+
rb_define_attr(cGDChart, "hard_graphwidth", 1, 1);
|
1040
|
+
rb_define_attr(cGDChart, "hard_yorig", 1, 1);
|
1041
|
+
rb_define_attr(cGDChart, "hard_grapheight", 1, 1);
|
1042
|
+
|
1043
|
+
rb_define_attr(cGDChart, "image_type", 1, 1);
|
1044
|
+
|
1045
|
+
/*
|
1046
|
+
* GDChartAnnotation class
|
1047
|
+
*/
|
1048
|
+
rb_define_singleton_method(cGDChartAnnotation, "new", gdc_annotation_new, 0);
|
1049
|
+
rb_define_method(cGDChartAnnotation, "initialize", gdc_annotation_init, 0);
|
1050
|
+
rb_define_attr(cGDChartAnnotation, "point", 1, 1);
|
1051
|
+
rb_define_attr(cGDChartAnnotation, "color", 1, 1);
|
1052
|
+
rb_define_attr(cGDChartAnnotation, "note", 1, 1);
|
1053
|
+
|
1054
|
+
/*
|
1055
|
+
* GDChartScatter class
|
1056
|
+
*/
|
1057
|
+
rb_define_singleton_method(cGDChartScatter, "new", gdc_scatter_new, 0);
|
1058
|
+
rb_define_method(cGDChartScatter, "initialize", gdc_scatter_init, 0);
|
1059
|
+
rb_define_attr(cGDChartScatter, "point", 1, 1);
|
1060
|
+
rb_define_attr(cGDChartScatter, "val", 1, 1);
|
1061
|
+
rb_define_attr(cGDChartScatter, "width", 1, 1);
|
1062
|
+
rb_define_attr(cGDChartScatter, "color", 1, 1);
|
1063
|
+
rb_define_attr(cGDChartScatter, "ind", 1, 1);
|
1064
|
+
|
1065
|
+
/* Scatter indicators */
|
1066
|
+
rb_define_const(cGDChartScatter, "SCATTER_TRIANGLE_DOWN",
|
1067
|
+
INT2FIX(GDC_SCATTER_TRIANGLE_DOWN));
|
1068
|
+
rb_define_const(cGDChartScatter, "SCATTER_TRIANGLE_UP",
|
1069
|
+
INT2FIX(GDC_SCATTER_TRIANGLE_UP));
|
1070
|
+
rb_define_const(cGDChartScatter, "SCATTER_CIRCLE",
|
1071
|
+
INT2FIX(GDC_SCATTER_CIRCLE));
|
1072
|
+
|
1073
|
+
|
1074
|
+
/*
|
1075
|
+
* GDChart Pie class
|
1076
|
+
*/
|
1077
|
+
|
1078
|
+
/* instance variable */
|
1079
|
+
DEFINE_COMPAT(cGDChartPie, "Color", "color");
|
1080
|
+
DEFINE_COMPAT(cGDChartPie, "BGColor", "bg_color");
|
1081
|
+
DEFINE_COMPAT(cGDChartPie, "PlotColor", "plot_color");
|
1082
|
+
DEFINE_COMPAT(cGDChartPie, "LineColor", "line_color");
|
1083
|
+
DEFINE_COMPAT(cGDChartPie, "EdgeColor", "edge_color");
|
1084
|
+
|
1085
|
+
rb_define_attr(cGDChartPie, "other_threshold", 1, 1);
|
1086
|
+
rb_define_attr(cGDChartPie, "angle_3d", 1, 1);
|
1087
|
+
rb_define_attr(cGDChartPie, "depth_3d", 1, 1);
|
1088
|
+
rb_define_attr(cGDChartPie, "perspective", 1, 1);
|
1089
|
+
rb_define_attr(cGDChartPie, "title", 1, 1);
|
1090
|
+
rb_define_attr(cGDChartPie, "title_size", 1, 1);
|
1091
|
+
rb_define_attr(cGDChartPie, "label_size", 1, 1);
|
1092
|
+
#ifdef HAVE_LIBFREETYPE
|
1093
|
+
rb_define_attr(cGDChartPie, "title_font", 1, 1);
|
1094
|
+
rb_define_attr(cGDChartPie, "label_font", 1, 1);
|
1095
|
+
rb_define_attr(cGDChartPie, "title_ptsize", 1, 1);
|
1096
|
+
rb_define_attr(cGDChartPie, "label_ptsize", 1, 1);
|
1097
|
+
#endif
|
1098
|
+
rb_define_attr(cGDChartPie, "label_dist", 1, 1);
|
1099
|
+
rb_define_attr(cGDChartPie, "label_line", 1, 1);
|
1100
|
+
rb_define_attr(cGDChartPie, "explode", 1, 1);
|
1101
|
+
rb_define_attr(cGDChartPie, "missing", 1, 1);
|
1102
|
+
rb_define_attr(cGDChartPie, "percent_labels", 1, 1);
|
1103
|
+
rb_define_attr(cGDChartPie, "percent_fmt", 1, 1);
|
1104
|
+
|
1105
|
+
rb_define_attr(cGDChartPie, "image_type", 1, 1);
|
1106
|
+
|
1107
|
+
/* method definitions */
|
1108
|
+
rb_define_singleton_method(cGDChartPie, "new", gdc_new, 0);
|
1109
|
+
rb_define_method(cGDChartPie, "initialize", gdc_initialize, 0);
|
1110
|
+
rb_define_method(cGDChartPie, "set_param", gdc_set_params, 0);
|
1111
|
+
|
1112
|
+
rb_define_method(cGDChartPie, "out_graph", gdc_pie_out_graph, -1);
|
1113
|
+
|
1114
|
+
/* constant */
|
1115
|
+
rb_define_const(cGDChartPie, "PIE3D", INT2FIX(GDC_3DPIE));
|
1116
|
+
rb_define_const(cGDChartPie, "PIE2D", INT2FIX(GDC_2DPIE));
|
1117
|
+
|
1118
|
+
rb_define_const(cGDChartPie, "PCT_NONE", INT2FIX(GDCPIE_PCT_NONE));
|
1119
|
+
rb_define_const(cGDChartPie, "PCT_ABOVE", INT2FIX(GDCPIE_PCT_ABOVE));
|
1120
|
+
rb_define_const(cGDChartPie, "PCT_BELOW", INT2FIX(GDCPIE_PCT_BELOW));
|
1121
|
+
rb_define_const(cGDChartPie, "PCT_RIGHT", INT2FIX(GDCPIE_PCT_RIGHT));
|
1122
|
+
rb_define_const(cGDChartPie, "PCT_LEFT", INT2FIX(GDCPIE_PCT_LEFT));
|
1123
|
+
}
|