ntcharts 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +309 -16
- data/ext/ntcharts/barchart.c +215 -0
- data/ext/ntcharts/extconf.rb +70 -0
- data/ext/ntcharts/extension.c +44 -0
- data/ext/ntcharts/extension.h +92 -0
- data/ext/ntcharts/linechart.c +341 -0
- data/ext/ntcharts/sparkline.c +161 -0
- data/ext/ntcharts/streamlinechart.c +183 -0
- data/ext/ntcharts/style.c +77 -0
- data/ext/ntcharts/timeserieslinechart.c +296 -0
- data/ext/ntcharts/wavelinechart.c +248 -0
- data/go/barchart.go +356 -0
- data/go/go.mod +32 -0
- data/go/go.sum +51 -0
- data/go/linechart.go +441 -0
- data/go/ntcharts.go +279 -0
- data/go/sparkline.go +194 -0
- data/go/streamlinechart.go +234 -0
- data/go/timeserieslinechart.go +354 -0
- data/go/wavelinechart.go +309 -0
- data/lib/ntcharts/bar_data.rb +51 -0
- data/lib/ntcharts/version.rb +1 -1
- data/lib/ntcharts.rb +95 -1
- data/ntcharts.gemspec +1 -0
- metadata +23 -2
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#include "extension.h"
|
|
2
|
+
|
|
3
|
+
static void streamlinechart_free(void *pointer) {
|
|
4
|
+
ntcharts_streamlinechart_t *chart = (ntcharts_streamlinechart_t *)pointer;
|
|
5
|
+
if (chart->handle != 0) {
|
|
6
|
+
ntcharts_streamlinechart_free(chart->handle);
|
|
7
|
+
}
|
|
8
|
+
xfree(chart);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static size_t streamlinechart_memsize(const void *pointer) {
|
|
12
|
+
return sizeof(ntcharts_streamlinechart_t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const rb_data_type_t streamlinechart_type = {
|
|
16
|
+
.wrap_struct_name = "Ntcharts::Streamlinechart",
|
|
17
|
+
.function = {
|
|
18
|
+
.dmark = NULL,
|
|
19
|
+
.dfree = streamlinechart_free,
|
|
20
|
+
.dsize = streamlinechart_memsize,
|
|
21
|
+
},
|
|
22
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static VALUE streamlinechart_alloc(VALUE klass) {
|
|
26
|
+
ntcharts_streamlinechart_t *chart = ALLOC(ntcharts_streamlinechart_t);
|
|
27
|
+
chart->handle = 0;
|
|
28
|
+
return TypedData_Wrap_Struct(klass, &streamlinechart_type, chart);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static VALUE streamlinechart_initialize(VALUE self, VALUE width, VALUE height) {
|
|
32
|
+
GET_STREAMLINECHART(self, chart);
|
|
33
|
+
chart->handle = ntcharts_streamlinechart_new(NUM2INT(width), NUM2INT(height));
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static VALUE streamlinechart_width(VALUE self) {
|
|
38
|
+
GET_STREAMLINECHART(self, chart);
|
|
39
|
+
return INT2NUM(ntcharts_streamlinechart_width(chart->handle));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static VALUE streamlinechart_height(VALUE self) {
|
|
43
|
+
GET_STREAMLINECHART(self, chart);
|
|
44
|
+
return INT2NUM(ntcharts_streamlinechart_height(chart->handle));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static VALUE streamlinechart_graph_width(VALUE self) {
|
|
48
|
+
GET_STREAMLINECHART(self, chart);
|
|
49
|
+
return INT2NUM(ntcharts_streamlinechart_graph_width(chart->handle));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static VALUE streamlinechart_graph_height(VALUE self) {
|
|
53
|
+
GET_STREAMLINECHART(self, chart);
|
|
54
|
+
return INT2NUM(ntcharts_streamlinechart_graph_height(chart->handle));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static VALUE streamlinechart_min_y(VALUE self) {
|
|
58
|
+
GET_STREAMLINECHART(self, chart);
|
|
59
|
+
return DBL2NUM(ntcharts_streamlinechart_min_y(chart->handle));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static VALUE streamlinechart_max_y(VALUE self) {
|
|
63
|
+
GET_STREAMLINECHART(self, chart);
|
|
64
|
+
return DBL2NUM(ntcharts_streamlinechart_max_y(chart->handle));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static VALUE streamlinechart_set_y_range(VALUE self, VALUE min_val, VALUE max_val) {
|
|
68
|
+
GET_STREAMLINECHART(self, chart);
|
|
69
|
+
ntcharts_streamlinechart_set_y_range(chart->handle, NUM2DBL(min_val), NUM2DBL(max_val));
|
|
70
|
+
return self;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static VALUE streamlinechart_set_view_y_range(VALUE self, VALUE min_val, VALUE max_val) {
|
|
74
|
+
GET_STREAMLINECHART(self, chart);
|
|
75
|
+
ntcharts_streamlinechart_set_view_y_range(chart->handle, NUM2DBL(min_val), NUM2DBL(max_val));
|
|
76
|
+
return self;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static VALUE streamlinechart_resize(VALUE self, VALUE width, VALUE height) {
|
|
80
|
+
GET_STREAMLINECHART(self, chart);
|
|
81
|
+
ntcharts_streamlinechart_resize(chart->handle, NUM2INT(width), NUM2INT(height));
|
|
82
|
+
return self;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static VALUE streamlinechart_clear(VALUE self) {
|
|
86
|
+
GET_STREAMLINECHART(self, chart);
|
|
87
|
+
ntcharts_streamlinechart_clear(chart->handle);
|
|
88
|
+
return self;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static VALUE streamlinechart_clear_data(VALUE self) {
|
|
92
|
+
GET_STREAMLINECHART(self, chart);
|
|
93
|
+
ntcharts_streamlinechart_clear_data(chart->handle);
|
|
94
|
+
return self;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static VALUE streamlinechart_push(VALUE self, VALUE value) {
|
|
98
|
+
GET_STREAMLINECHART(self, chart);
|
|
99
|
+
ntcharts_streamlinechart_push(chart->handle, NUM2DBL(value));
|
|
100
|
+
return self;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static VALUE streamlinechart_set_style(VALUE self, VALUE style) {
|
|
104
|
+
GET_STREAMLINECHART(self, chart);
|
|
105
|
+
ntcharts_style_t *style_ptr;
|
|
106
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
107
|
+
ntcharts_streamlinechart_set_style(chart->handle, style_ptr->handle);
|
|
108
|
+
return self;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static VALUE streamlinechart_set_axis_style(VALUE self, VALUE style) {
|
|
112
|
+
GET_STREAMLINECHART(self, chart);
|
|
113
|
+
ntcharts_style_t *style_ptr;
|
|
114
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
115
|
+
ntcharts_streamlinechart_set_axis_style(chart->handle, style_ptr->handle);
|
|
116
|
+
return self;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static VALUE streamlinechart_set_label_style(VALUE self, VALUE style) {
|
|
120
|
+
GET_STREAMLINECHART(self, chart);
|
|
121
|
+
ntcharts_style_t *style_ptr;
|
|
122
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
123
|
+
ntcharts_streamlinechart_set_label_style(chart->handle, style_ptr->handle);
|
|
124
|
+
return self;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static VALUE streamlinechart_draw(VALUE self) {
|
|
128
|
+
GET_STREAMLINECHART(self, chart);
|
|
129
|
+
ntcharts_streamlinechart_draw(chart->handle);
|
|
130
|
+
return self;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static VALUE streamlinechart_view(VALUE self) {
|
|
134
|
+
GET_STREAMLINECHART(self, chart);
|
|
135
|
+
char *result = ntcharts_streamlinechart_view(chart->handle);
|
|
136
|
+
VALUE rb_result = rb_utf8_str_new_cstr(result);
|
|
137
|
+
ntcharts_free(result);
|
|
138
|
+
return rb_result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static VALUE streamlinechart_render(VALUE self) {
|
|
142
|
+
streamlinechart_draw(self);
|
|
143
|
+
return streamlinechart_view(self);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static VALUE streamlinechart_to_s(VALUE self) {
|
|
147
|
+
return streamlinechart_view(self);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
void Init_ntcharts_streamlinechart(void) {
|
|
151
|
+
cStreamlinechart = rb_define_class_under(mNtcharts, "Streamlinechart", rb_cObject);
|
|
152
|
+
|
|
153
|
+
rb_define_alloc_func(cStreamlinechart, streamlinechart_alloc);
|
|
154
|
+
rb_define_method(cStreamlinechart, "initialize", streamlinechart_initialize, 2);
|
|
155
|
+
|
|
156
|
+
rb_define_method(cStreamlinechart, "width", streamlinechart_width, 0);
|
|
157
|
+
rb_define_method(cStreamlinechart, "height", streamlinechart_height, 0);
|
|
158
|
+
rb_define_method(cStreamlinechart, "graph_width", streamlinechart_graph_width, 0);
|
|
159
|
+
rb_define_method(cStreamlinechart, "graph_height", streamlinechart_graph_height, 0);
|
|
160
|
+
|
|
161
|
+
rb_define_method(cStreamlinechart, "min_y", streamlinechart_min_y, 0);
|
|
162
|
+
rb_define_method(cStreamlinechart, "max_y", streamlinechart_max_y, 0);
|
|
163
|
+
|
|
164
|
+
rb_define_method(cStreamlinechart, "set_y_range", streamlinechart_set_y_range, 2);
|
|
165
|
+
rb_define_method(cStreamlinechart, "set_view_y_range", streamlinechart_set_view_y_range, 2);
|
|
166
|
+
|
|
167
|
+
rb_define_method(cStreamlinechart, "resize", streamlinechart_resize, 2);
|
|
168
|
+
rb_define_method(cStreamlinechart, "clear", streamlinechart_clear, 0);
|
|
169
|
+
rb_define_method(cStreamlinechart, "clear_data", streamlinechart_clear_data, 0);
|
|
170
|
+
rb_define_method(cStreamlinechart, "push", streamlinechart_push, 1);
|
|
171
|
+
|
|
172
|
+
rb_define_method(cStreamlinechart, "_set_style", streamlinechart_set_style, 1);
|
|
173
|
+
rb_define_method(cStreamlinechart, "_set_axis_style", streamlinechart_set_axis_style, 1);
|
|
174
|
+
rb_define_method(cStreamlinechart, "_set_label_style", streamlinechart_set_label_style, 1);
|
|
175
|
+
|
|
176
|
+
rb_define_method(cStreamlinechart, "draw", streamlinechart_draw, 0);
|
|
177
|
+
rb_define_method(cStreamlinechart, "view", streamlinechart_view, 0);
|
|
178
|
+
rb_define_method(cStreamlinechart, "render", streamlinechart_render, 0);
|
|
179
|
+
rb_define_method(cStreamlinechart, "to_s", streamlinechart_to_s, 0);
|
|
180
|
+
|
|
181
|
+
rb_define_const(cStreamlinechart, "LINE_STYLE_THIN", INT2NUM(0));
|
|
182
|
+
rb_define_const(cStreamlinechart, "LINE_STYLE_ARC", INT2NUM(1));
|
|
183
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#include "extension.h"
|
|
2
|
+
|
|
3
|
+
static void style_free(void *pointer) {
|
|
4
|
+
ntcharts_style_t *style = (ntcharts_style_t *)pointer;
|
|
5
|
+
if (style->handle != 0) {
|
|
6
|
+
ntcharts_style_free(style->handle);
|
|
7
|
+
}
|
|
8
|
+
xfree(style);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static size_t style_memsize(const void *pointer) {
|
|
12
|
+
return sizeof(ntcharts_style_t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const rb_data_type_t style_type = {
|
|
16
|
+
.wrap_struct_name = "Ntcharts::Style",
|
|
17
|
+
.function = {
|
|
18
|
+
.dmark = NULL,
|
|
19
|
+
.dfree = style_free,
|
|
20
|
+
.dsize = style_memsize,
|
|
21
|
+
},
|
|
22
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static VALUE style_alloc(VALUE klass) {
|
|
26
|
+
ntcharts_style_t *style = ALLOC(ntcharts_style_t);
|
|
27
|
+
style->handle = 0;
|
|
28
|
+
return TypedData_Wrap_Struct(klass, &style_type, style);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALUE style_wrap(VALUE klass, unsigned long long handle) {
|
|
32
|
+
ntcharts_style_t *style = ALLOC(ntcharts_style_t);
|
|
33
|
+
style->handle = handle;
|
|
34
|
+
return TypedData_Wrap_Struct(klass, &style_type, style);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static VALUE style_initialize(VALUE self) {
|
|
38
|
+
GET_STYLE(self, style);
|
|
39
|
+
style->handle = ntcharts_style_new();
|
|
40
|
+
return self;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static VALUE style_foreground(VALUE self, VALUE color) {
|
|
44
|
+
GET_STYLE(self, style);
|
|
45
|
+
Check_Type(color, T_STRING);
|
|
46
|
+
unsigned long long new_handle = ntcharts_style_foreground(style->handle, StringValueCStr(color));
|
|
47
|
+
return style_wrap(rb_class_of(self), new_handle);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE style_background(VALUE self, VALUE color) {
|
|
51
|
+
GET_STYLE(self, style);
|
|
52
|
+
Check_Type(color, T_STRING);
|
|
53
|
+
unsigned long long new_handle = ntcharts_style_background(style->handle, StringValueCStr(color));
|
|
54
|
+
return style_wrap(rb_class_of(self), new_handle);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static VALUE style_bold(VALUE self, VALUE bold_val) {
|
|
58
|
+
GET_STYLE(self, style);
|
|
59
|
+
unsigned long long new_handle = ntcharts_style_bold(style->handle, RTEST(bold_val) ? 1 : 0);
|
|
60
|
+
return style_wrap(rb_class_of(self), new_handle);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static VALUE style_handle(VALUE self) {
|
|
64
|
+
GET_STYLE(self, style);
|
|
65
|
+
return ULL2NUM(style->handle);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void Init_ntcharts_style(void) {
|
|
69
|
+
cStyle = rb_define_class_under(mNtcharts, "Style", rb_cObject);
|
|
70
|
+
|
|
71
|
+
rb_define_alloc_func(cStyle, style_alloc);
|
|
72
|
+
rb_define_method(cStyle, "initialize", style_initialize, 0);
|
|
73
|
+
rb_define_method(cStyle, "foreground", style_foreground, 1);
|
|
74
|
+
rb_define_method(cStyle, "background", style_background, 1);
|
|
75
|
+
rb_define_method(cStyle, "bold", style_bold, 1);
|
|
76
|
+
rb_define_method(cStyle, "handle", style_handle, 0);
|
|
77
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#include "extension.h"
|
|
2
|
+
|
|
3
|
+
static void timeserieslinechart_free(void *pointer) {
|
|
4
|
+
ntcharts_timeserieslinechart_t *chart = (ntcharts_timeserieslinechart_t *)pointer;
|
|
5
|
+
if (chart->handle != 0) {
|
|
6
|
+
ntcharts_timeserieslinechart_free(chart->handle);
|
|
7
|
+
}
|
|
8
|
+
xfree(chart);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static size_t timeserieslinechart_memsize(const void *pointer) {
|
|
12
|
+
return sizeof(ntcharts_timeserieslinechart_t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const rb_data_type_t timeserieslinechart_type = {
|
|
16
|
+
.wrap_struct_name = "Ntcharts::Timeserieslinechart",
|
|
17
|
+
.function = {
|
|
18
|
+
.dmark = NULL,
|
|
19
|
+
.dfree = timeserieslinechart_free,
|
|
20
|
+
.dsize = timeserieslinechart_memsize,
|
|
21
|
+
},
|
|
22
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static VALUE timeserieslinechart_alloc(VALUE klass) {
|
|
26
|
+
ntcharts_timeserieslinechart_t *chart = ALLOC(ntcharts_timeserieslinechart_t);
|
|
27
|
+
chart->handle = 0;
|
|
28
|
+
return TypedData_Wrap_Struct(klass, ×erieslinechart_type, chart);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static VALUE timeserieslinechart_initialize(VALUE self, VALUE width, VALUE height) {
|
|
32
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
33
|
+
chart->handle = ntcharts_timeserieslinechart_new(NUM2INT(width), NUM2INT(height));
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static VALUE timeserieslinechart_width(VALUE self) {
|
|
38
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
39
|
+
return INT2NUM(ntcharts_timeserieslinechart_width(chart->handle));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static VALUE timeserieslinechart_height(VALUE self) {
|
|
43
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
44
|
+
return INT2NUM(ntcharts_timeserieslinechart_height(chart->handle));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static VALUE timeserieslinechart_graph_width(VALUE self) {
|
|
48
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
49
|
+
return INT2NUM(ntcharts_timeserieslinechart_graph_width(chart->handle));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static VALUE timeserieslinechart_graph_height(VALUE self) {
|
|
53
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
54
|
+
return INT2NUM(ntcharts_timeserieslinechart_graph_height(chart->handle));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static VALUE timeserieslinechart_min_x(VALUE self) {
|
|
58
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
59
|
+
long long unix_time = ntcharts_timeserieslinechart_min_x(chart->handle);
|
|
60
|
+
return rb_funcall(rb_cTime, rb_intern("at"), 1, LL2NUM(unix_time));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static VALUE timeserieslinechart_max_x(VALUE self) {
|
|
64
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
65
|
+
long long unix_time = ntcharts_timeserieslinechart_max_x(chart->handle);
|
|
66
|
+
return rb_funcall(rb_cTime, rb_intern("at"), 1, LL2NUM(unix_time));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static VALUE timeserieslinechart_min_y(VALUE self) {
|
|
70
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
71
|
+
return DBL2NUM(ntcharts_timeserieslinechart_min_y(chart->handle));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static VALUE timeserieslinechart_max_y(VALUE self) {
|
|
75
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
76
|
+
return DBL2NUM(ntcharts_timeserieslinechart_max_y(chart->handle));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static long long time_to_unix(VALUE time) {
|
|
80
|
+
if (rb_obj_is_kind_of(time, rb_cTime)) {
|
|
81
|
+
return NUM2LL(rb_funcall(time, rb_intern("to_i"), 0));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return NUM2LL(time);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static VALUE timeserieslinechart_set_time_range(VALUE self, VALUE min_time, VALUE max_time) {
|
|
88
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
89
|
+
ntcharts_timeserieslinechart_set_time_range(chart->handle, time_to_unix(min_time), time_to_unix(max_time));
|
|
90
|
+
return self;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static VALUE timeserieslinechart_set_y_range(VALUE self, VALUE min_val, VALUE max_val) {
|
|
94
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
95
|
+
ntcharts_timeserieslinechart_set_y_range(chart->handle, NUM2DBL(min_val), NUM2DBL(max_val));
|
|
96
|
+
return self;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static VALUE timeserieslinechart_set_view_time_range(VALUE self, VALUE min_time, VALUE max_time) {
|
|
100
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
101
|
+
ntcharts_timeserieslinechart_set_view_time_range(chart->handle, time_to_unix(min_time), time_to_unix(max_time));
|
|
102
|
+
return self;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static VALUE timeserieslinechart_set_view_y_range(VALUE self, VALUE min_val, VALUE max_val) {
|
|
106
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
107
|
+
ntcharts_timeserieslinechart_set_view_y_range(chart->handle, NUM2DBL(min_val), NUM2DBL(max_val));
|
|
108
|
+
return self;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static VALUE timeserieslinechart_resize(VALUE self, VALUE width, VALUE height) {
|
|
112
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
113
|
+
ntcharts_timeserieslinechart_resize(chart->handle, NUM2INT(width), NUM2INT(height));
|
|
114
|
+
return self;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static VALUE timeserieslinechart_clear(VALUE self) {
|
|
118
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
119
|
+
ntcharts_timeserieslinechart_clear(chart->handle);
|
|
120
|
+
return self;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static VALUE timeserieslinechart_clear_all_data(VALUE self) {
|
|
124
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
125
|
+
ntcharts_timeserieslinechart_clear_all_data(chart->handle);
|
|
126
|
+
return self;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static VALUE timeserieslinechart_clear_data_set(VALUE self, VALUE name) {
|
|
130
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
131
|
+
ntcharts_timeserieslinechart_clear_data_set(chart->handle, StringValueCStr(name));
|
|
132
|
+
return self;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static VALUE timeserieslinechart_push(VALUE self, VALUE time, VALUE value) {
|
|
136
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
137
|
+
ntcharts_timeserieslinechart_push(chart->handle, time_to_unix(time), NUM2DBL(value));
|
|
138
|
+
return self;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static VALUE timeserieslinechart_push_data_set(VALUE self, VALUE name, VALUE time, VALUE value) {
|
|
142
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
143
|
+
ntcharts_timeserieslinechart_push_data_set(chart->handle, StringValueCStr(name), time_to_unix(time), NUM2DBL(value));
|
|
144
|
+
return self;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static VALUE timeserieslinechart_set_line_style(VALUE self, VALUE line_style) {
|
|
148
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
149
|
+
ntcharts_timeserieslinechart_set_line_style(chart->handle, NUM2INT(line_style));
|
|
150
|
+
return self;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static VALUE timeserieslinechart_set_style(VALUE self, VALUE style) {
|
|
154
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
155
|
+
ntcharts_style_t *style_ptr;
|
|
156
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
157
|
+
ntcharts_timeserieslinechart_set_style(chart->handle, style_ptr->handle);
|
|
158
|
+
return self;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static VALUE timeserieslinechart_set_data_set_line_style(VALUE self, VALUE name, VALUE line_style) {
|
|
162
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
163
|
+
ntcharts_timeserieslinechart_set_data_set_line_style(chart->handle, StringValueCStr(name), NUM2INT(line_style));
|
|
164
|
+
return self;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static VALUE timeserieslinechart_set_data_set_style(VALUE self, VALUE name, VALUE style) {
|
|
168
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
169
|
+
ntcharts_style_t *style_ptr;
|
|
170
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
171
|
+
ntcharts_timeserieslinechart_set_data_set_style(chart->handle, StringValueCStr(name), style_ptr->handle);
|
|
172
|
+
return self;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static VALUE timeserieslinechart_set_axis_style(VALUE self, VALUE style) {
|
|
176
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
177
|
+
ntcharts_style_t *style_ptr;
|
|
178
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
179
|
+
ntcharts_timeserieslinechart_set_axis_style(chart->handle, style_ptr->handle);
|
|
180
|
+
return self;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static VALUE timeserieslinechart_set_label_style(VALUE self, VALUE style) {
|
|
184
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
185
|
+
ntcharts_style_t *style_ptr;
|
|
186
|
+
TypedData_Get_Struct(style, ntcharts_style_t, &style_type, style_ptr);
|
|
187
|
+
ntcharts_timeserieslinechart_set_label_style(chart->handle, style_ptr->handle);
|
|
188
|
+
return self;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static VALUE timeserieslinechart_draw(VALUE self) {
|
|
192
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
193
|
+
ntcharts_timeserieslinechart_draw(chart->handle);
|
|
194
|
+
return self;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static VALUE timeserieslinechart_draw_all(VALUE self) {
|
|
198
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
199
|
+
ntcharts_timeserieslinechart_draw_all(chart->handle);
|
|
200
|
+
return self;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static VALUE timeserieslinechart_draw_braille(VALUE self) {
|
|
204
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
205
|
+
ntcharts_timeserieslinechart_draw_braille(chart->handle);
|
|
206
|
+
return self;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static VALUE timeserieslinechart_draw_braille_all(VALUE self) {
|
|
210
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
211
|
+
ntcharts_timeserieslinechart_draw_braille_all(chart->handle);
|
|
212
|
+
return self;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static VALUE timeserieslinechart_view(VALUE self) {
|
|
216
|
+
GET_TIMESERIESLINECHART(self, chart);
|
|
217
|
+
char *result = ntcharts_timeserieslinechart_view(chart->handle);
|
|
218
|
+
VALUE rb_result = rb_utf8_str_new_cstr(result);
|
|
219
|
+
ntcharts_free(result);
|
|
220
|
+
return rb_result;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
static VALUE timeserieslinechart_render(VALUE self) {
|
|
224
|
+
timeserieslinechart_draw(self);
|
|
225
|
+
return timeserieslinechart_view(self);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static VALUE timeserieslinechart_render_all(VALUE self) {
|
|
229
|
+
timeserieslinechart_draw_all(self);
|
|
230
|
+
return timeserieslinechart_view(self);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static VALUE timeserieslinechart_render_braille(VALUE self) {
|
|
234
|
+
timeserieslinechart_draw_braille(self);
|
|
235
|
+
return timeserieslinechart_view(self);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
static VALUE timeserieslinechart_render_braille_all(VALUE self) {
|
|
239
|
+
timeserieslinechart_draw_braille_all(self);
|
|
240
|
+
return timeserieslinechart_view(self);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static VALUE timeserieslinechart_to_s(VALUE self) {
|
|
244
|
+
return timeserieslinechart_view(self);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void Init_ntcharts_timeserieslinechart(void) {
|
|
248
|
+
cTimeserieslinechart = rb_define_class_under(mNtcharts, "Timeserieslinechart", rb_cObject);
|
|
249
|
+
|
|
250
|
+
rb_define_alloc_func(cTimeserieslinechart, timeserieslinechart_alloc);
|
|
251
|
+
rb_define_method(cTimeserieslinechart, "initialize", timeserieslinechart_initialize, 2);
|
|
252
|
+
|
|
253
|
+
rb_define_method(cTimeserieslinechart, "width", timeserieslinechart_width, 0);
|
|
254
|
+
rb_define_method(cTimeserieslinechart, "height", timeserieslinechart_height, 0);
|
|
255
|
+
rb_define_method(cTimeserieslinechart, "graph_width", timeserieslinechart_graph_width, 0);
|
|
256
|
+
rb_define_method(cTimeserieslinechart, "graph_height", timeserieslinechart_graph_height, 0);
|
|
257
|
+
|
|
258
|
+
rb_define_method(cTimeserieslinechart, "min_x", timeserieslinechart_min_x, 0);
|
|
259
|
+
rb_define_method(cTimeserieslinechart, "max_x", timeserieslinechart_max_x, 0);
|
|
260
|
+
rb_define_method(cTimeserieslinechart, "min_y", timeserieslinechart_min_y, 0);
|
|
261
|
+
rb_define_method(cTimeserieslinechart, "max_y", timeserieslinechart_max_y, 0);
|
|
262
|
+
|
|
263
|
+
rb_define_method(cTimeserieslinechart, "set_time_range", timeserieslinechart_set_time_range, 2);
|
|
264
|
+
rb_define_method(cTimeserieslinechart, "set_y_range", timeserieslinechart_set_y_range, 2);
|
|
265
|
+
rb_define_method(cTimeserieslinechart, "set_view_time_range", timeserieslinechart_set_view_time_range, 2);
|
|
266
|
+
rb_define_method(cTimeserieslinechart, "set_view_y_range", timeserieslinechart_set_view_y_range, 2);
|
|
267
|
+
|
|
268
|
+
rb_define_method(cTimeserieslinechart, "resize", timeserieslinechart_resize, 2);
|
|
269
|
+
rb_define_method(cTimeserieslinechart, "clear", timeserieslinechart_clear, 0);
|
|
270
|
+
rb_define_method(cTimeserieslinechart, "clear_all_data", timeserieslinechart_clear_all_data, 0);
|
|
271
|
+
rb_define_method(cTimeserieslinechart, "clear_data_set", timeserieslinechart_clear_data_set, 1);
|
|
272
|
+
|
|
273
|
+
rb_define_method(cTimeserieslinechart, "push", timeserieslinechart_push, 2);
|
|
274
|
+
rb_define_method(cTimeserieslinechart, "push_data_set", timeserieslinechart_push_data_set, 3);
|
|
275
|
+
|
|
276
|
+
rb_define_method(cTimeserieslinechart, "line_style=", timeserieslinechart_set_line_style, 1);
|
|
277
|
+
rb_define_method(cTimeserieslinechart, "_set_style", timeserieslinechart_set_style, 1);
|
|
278
|
+
rb_define_method(cTimeserieslinechart, "set_data_set_line_style", timeserieslinechart_set_data_set_line_style, 2);
|
|
279
|
+
rb_define_method(cTimeserieslinechart, "set_data_set_style", timeserieslinechart_set_data_set_style, 2);
|
|
280
|
+
rb_define_method(cTimeserieslinechart, "_set_axis_style", timeserieslinechart_set_axis_style, 1);
|
|
281
|
+
rb_define_method(cTimeserieslinechart, "_set_label_style", timeserieslinechart_set_label_style, 1);
|
|
282
|
+
|
|
283
|
+
rb_define_method(cTimeserieslinechart, "draw", timeserieslinechart_draw, 0);
|
|
284
|
+
rb_define_method(cTimeserieslinechart, "draw_all", timeserieslinechart_draw_all, 0);
|
|
285
|
+
rb_define_method(cTimeserieslinechart, "draw_braille", timeserieslinechart_draw_braille, 0);
|
|
286
|
+
rb_define_method(cTimeserieslinechart, "draw_braille_all", timeserieslinechart_draw_braille_all, 0);
|
|
287
|
+
rb_define_method(cTimeserieslinechart, "view", timeserieslinechart_view, 0);
|
|
288
|
+
rb_define_method(cTimeserieslinechart, "render", timeserieslinechart_render, 0);
|
|
289
|
+
rb_define_method(cTimeserieslinechart, "render_all", timeserieslinechart_render_all, 0);
|
|
290
|
+
rb_define_method(cTimeserieslinechart, "render_braille", timeserieslinechart_render_braille, 0);
|
|
291
|
+
rb_define_method(cTimeserieslinechart, "render_braille_all", timeserieslinechart_render_braille_all, 0);
|
|
292
|
+
rb_define_method(cTimeserieslinechart, "to_s", timeserieslinechart_to_s, 0);
|
|
293
|
+
|
|
294
|
+
rb_define_const(cTimeserieslinechart, "LINE_STYLE_THIN", INT2NUM(0));
|
|
295
|
+
rb_define_const(cTimeserieslinechart, "LINE_STYLE_ARC", INT2NUM(1));
|
|
296
|
+
}
|