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:
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'ext/xlsxwriter/chart.c', line 80
VALUE
chart_init(VALUE self, VALUE workbook, VALUE type) {
struct chart *ptr;
struct workbook *wb_ptr;
TypedData_Get_Struct(workbook, struct workbook, &workbook_type, wb_ptr);
TypedData_Get_Struct(self, struct chart, &chart_type, 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.
176 177 178 179 180 181 182 |
# File 'ext/xlsxwriter/chart.c', line 176
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:
315 316 317 318 319 320 |
# File 'ext/xlsxwriter/chart.c', line 315
VALUE
chart_get_axis_id_1_(VALUE self) {
struct chart *ptr;
TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
return UINT2NUM(ptr->chart->axis_id_1);
}
|
#axis_id_1=(val) ⇒ Object
:nodoc:
323 324 325 326 327 328 329 |
# File 'ext/xlsxwriter/chart.c', line 323
VALUE
chart_set_axis_id_1_(VALUE self, VALUE val) {
struct chart *ptr;
TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
ptr->chart->axis_id_1 = NUM2UINT(rb_check_to_int(val));
return val;
}
|
#axis_id_2 ⇒ Object
:nodoc:
332 333 334 335 336 337 |
# File 'ext/xlsxwriter/chart.c', line 332
VALUE
chart_get_axis_id_2_(VALUE self) {
struct chart *ptr;
TypedData_Get_Struct(self, struct chart, &chart_type, ptr);
return UINT2NUM(ptr->chart->axis_id_2);
}
|
#axis_id_2=(val) ⇒ Object
:nodoc:
340 341 342 343 344 345 346 |
# File 'ext/xlsxwriter/chart.c', line 340
VALUE
chart_set_axis_id_2_(VALUE self, VALUE val) {
struct chart *ptr;
TypedData_Get_Struct(self, struct chart, &chart_type, 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])
268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'ext/xlsxwriter/chart.c', line 268
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}
.
244 245 246 247 248 |
# File 'ext/xlsxwriter/chart.c', line 244
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).
255 256 257 258 259 260 |
# File 'ext/xlsxwriter/chart.c', line 255
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
.
226 227 228 229 230 231 232 233 234 235 236 |
# File 'ext/xlsxwriter/chart.c', line 226
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.
206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'ext/xlsxwriter/chart.c', line 206
VALUE
chart_title_set_name_(VALUE self, VALUE name) {
struct chart *ptr;
TypedData_Get_Struct(self, struct chart, &chart_type, 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
188 189 190 191 |
# File 'ext/xlsxwriter/chart.c', line 188 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
197 198 199 200 |
# File 'ext/xlsxwriter/chart.c', line 197 VALUE chart_y_axis_(VALUE self) { return rb_funcall(cChartAxis, rb_intern("new"), 2, self, ID2SYM(rb_intern("y"))); } |