Class: XlsxWriter::Workbook::Chart
- Inherits:
-
Object
- Object
- XlsxWriter::Workbook::Chart
- Defined in:
- ext/xlsxwriter/chart.c
Defined Under Namespace
Instance Attribute Summary collapse
- #workbook ⇒ Object readonly
Instance Method Summary collapse
-
#add_series([categories,]) ⇒ self
Adds data series to the chart.
-
#axis_id_1 ⇒ Object
:nodoc:.
-
#axis_id_1=(val) ⇒ Object
:nodoc:.
-
#axis_id_2 ⇒ Object
:nodoc:.
-
#axis_id_2=(val) ⇒ Object
:nodoc:.
- #hole_size= ⇒ Object
-
#initialize(workbook, type) ⇒ Object
constructor
:nodoc:.
-
#legend_delete_series(series) ⇒ self
Deletes series by 0-based indexes from the chart legend.
-
#legend_position=(position) ⇒ Object
Sets the chart legend position, one of
Chart::{LEGEND_NONE, LEGEND_RIGHT, LEGEND_LEFT, LEGEND_TOP, LEGEND_BOTTOM, LEGEND_OVERLAY_RIGHT, LEGEND_OVERLAY_LEFT}
. -
#legend_set_font(options) ⇒ self
Sets legend font from options (name, size, bold, italic, underline, rotation, color, baseline).
- #rotation= ⇒ Object
-
#set_name_range(*args) ⇒ Object
Sets the chart title range (
cell
) andname
. - #show_blank_as= ⇒ Object
-
#style= ⇒ Object
call-seq: chart.style=(style) -> style.
-
#title=(title) ⇒ Object
Sets the chart title.
-
#x_axis ⇒ Chart::Axis
Returns x axis as Chart::Axis.
-
#y_axis ⇒ Chart::Axis
Returns y axis as Chart::Axis.
Constructor Details
#initialize(workbook, type) ⇒ Object
:nodoc:
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'ext/xlsxwriter/chart.c', line 34
VALUE
chart_init(VALUE self, VALUE workbook, VALUE type) {
struct chart *ptr;
struct workbook *wb_ptr;
Data_Get_Struct(workbook, struct workbook, wb_ptr);
Data_Get_Struct(self, struct chart, ptr);
if (wb_ptr && wb_ptr->workbook) {
ptr->chart = workbook_add_chart(wb_ptr->workbook, NUM2INT(type));
}
rb_iv_set(self, "@workbook", workbook);
return self;
}
|
Instance Attribute Details
#workbook ⇒ Object (readonly)
Instance Method Details
#add_series([categories,]) ⇒ self
Adds data series to the chart.
130 131 132 133 134 135 136 |
# File 'ext/xlsxwriter/chart.c', line 130
VALUE
chart_add_series_(int argc, VALUE *argv, VALUE self) {
rb_check_arity(argc, 0, 2);
VALUE series = rb_funcall(cChartSeries, rb_intern("new"), argc+1, self, argv[0], argv[1]);
return series;
}
|
#axis_id_1 ⇒ Object
:nodoc:
269 270 271 272 273 274 |
# File 'ext/xlsxwriter/chart.c', line 269
VALUE
chart_get_axis_id_1_(VALUE self) {
struct chart *ptr;
Data_Get_Struct(self, struct chart, ptr);
return UINT2NUM(ptr->chart->axis_id_1);
}
|
#axis_id_1=(val) ⇒ Object
:nodoc:
277 278 279 280 281 282 283 |
# File 'ext/xlsxwriter/chart.c', line 277
VALUE
chart_set_axis_id_1_(VALUE self, VALUE val) {
struct chart *ptr;
Data_Get_Struct(self, struct chart, ptr);
ptr->chart->axis_id_1 = NUM2UINT(rb_check_to_int(val));
return val;
}
|
#axis_id_2 ⇒ Object
:nodoc:
286 287 288 289 290 291 |
# File 'ext/xlsxwriter/chart.c', line 286
VALUE
chart_get_axis_id_2_(VALUE self) {
struct chart *ptr;
Data_Get_Struct(self, struct chart, ptr);
return UINT2NUM(ptr->chart->axis_id_2);
}
|
#axis_id_2=(val) ⇒ Object
:nodoc:
294 295 296 297 298 299 300 |
# File 'ext/xlsxwriter/chart.c', line 294
VALUE
chart_set_axis_id_2_(VALUE self, VALUE val) {
struct chart *ptr;
Data_Get_Struct(self, struct chart, ptr);
ptr->chart->axis_id_2 = NUM2UINT(rb_check_to_int(val));
return val;
}
|
#hole_size= ⇒ Object
#legend_delete_series(series) ⇒ self
Deletes series by 0-based indexes from the chart legend.
chart.legend_delete_series([0, 2])
222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'ext/xlsxwriter/chart.c', line 222
VALUE
chart_legend_delete_series_(VALUE self, VALUE series) {
series = rb_check_array_type(series);
const size_t len = RARRAY_LEN(series);
int16_t series_arr[len+1];
size_t i;
for (i = 0; i < len; ++i) {
series_arr[i] = NUM2INT(rb_check_to_int(rb_ary_entry(series, i)));
}
series_arr[len] = -1;
LXW_ERR_RESULT_CALL(chart, legend_delete_series, series_arr);
return self;
}
|
#legend_position=(position) ⇒ Object
Sets the chart legend position, one of Chart::{LEGEND_NONE, LEGEND_RIGHT, LEGEND_LEFT, LEGEND_TOP, LEGEND_BOTTOM, LEGEND_OVERLAY_RIGHT, LEGEND_OVERLAY_LEFT}
.
198 199 200 201 202 |
# File 'ext/xlsxwriter/chart.c', line 198
VALUE
chart_legend_set_position_(VALUE self, VALUE pos) {
LXW_NO_RESULT_CALL(chart, legend_set_position, NUM2UINT(rb_check_to_int(pos)));
return pos;
}
|
#legend_set_font(options) ⇒ self
Sets legend font from options (name, size, bold, italic, underline, rotation, color, baseline).
209 210 211 212 213 214 |
# File 'ext/xlsxwriter/chart.c', line 209
VALUE
chart_legend_set_font_(VALUE self, VALUE opts) {
lxw_chart_font font = val_to_lxw_chart_font(opts);
LXW_NO_RESULT_CALL(chart, legend_set_font, &font);
return self;
}
|
#rotation= ⇒ Object
#set_name_range(name, cell) ⇒ self #set_name_range(name, row, col) ⇒ self
Sets the chart title range (cell
) and name
.
180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/xlsxwriter/chart.c', line 180
VALUE
chart_title_set_name_range_(int argc, VALUE *argv, VALUE self) {
rb_check_arity(argc, 2, 3);
const char *str = StringValueCStr(argv[0]);
lxw_row_t row;
lxw_col_t col;
extract_cell(argc - 1, argv + 1, &row, &col);
LXW_NO_RESULT_CALL(chart, title_set_name_range, str, row, col);
return self;
}
|
#show_blank_as= ⇒ Object
#style= ⇒ Object
call-seq: chart.style=(style) -> style
Sets the chart style
(integer from 1 to 48, default is 2).
#title=(title) ⇒ Object
Sets the chart title.
160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'ext/xlsxwriter/chart.c', line 160
VALUE
chart_title_set_name_(VALUE self, VALUE name) {
struct chart *ptr;
Data_Get_Struct(self, struct chart, ptr);
if (RTEST(name)) {
chart_title_set_name(ptr->chart, StringValueCStr(name));
} else {
chart_title_off(ptr->chart);
}
return name;
}
|
#x_axis ⇒ Chart::Axis
Returns x axis as Chart::Axis
142 143 144 145 |
# File 'ext/xlsxwriter/chart.c', line 142 VALUE chart_x_axis_(VALUE self) { return rb_funcall(cChartAxis, rb_intern("new"), 2, self, ID2SYM(rb_intern("x"))); } |
#y_axis ⇒ Chart::Axis
Returns y axis as Chart::Axis
151 152 153 154 |
# File 'ext/xlsxwriter/chart.c', line 151 VALUE chart_y_axis_(VALUE self) { return rb_funcall(cChartAxis, rb_intern("new"), 2, self, ID2SYM(rb_intern("y"))); } |