Class: XlsxWriter::Workbook::Chart
- Inherits:
-
Object
- Object
- XlsxWriter::Workbook::Chart
- Defined in:
- ext/xlsxwriter/chart.c
Defined Under Namespace
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=(size) ⇒ Object
:nodoc:.
-
#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=(rotation) ⇒ Object
:nodoc:.
-
#style=(style) ⇒ Object
Sets the chart
style(integer from 1 to 48, default is 2). -
#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:
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'ext/xlsxwriter/chart.c', line 24 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 Method Details
#add_series([categories,]) ⇒ self
Adds data series to the chart.
120 121 122 123 124 125 126 |
# File 'ext/xlsxwriter/chart.c', line 120 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:
270 271 272 273 274 275 |
# File 'ext/xlsxwriter/chart.c', line 270 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:
278 279 280 281 282 283 284 |
# File 'ext/xlsxwriter/chart.c', line 278 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(val); return val; } |
#axis_id_2 ⇒ Object
:nodoc:
287 288 289 290 291 292 |
# File 'ext/xlsxwriter/chart.c', line 287 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:
295 296 297 298 299 300 301 |
# File 'ext/xlsxwriter/chart.c', line 295 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(val); return val; } |
#hole_size=(size) ⇒ Object
:nodoc:
259 260 261 262 263 264 265 266 |
# File 'ext/xlsxwriter/chart.c', line 259 VALUE chart_set_hole_size_(VALUE self, VALUE size) { struct chart *ptr; Data_Get_Struct(self, struct chart, ptr); chart_set_hole_size(ptr->chart, NUM2UINT(rb_check_to_int(size))); return size; } |
#legend_delete_series(series) ⇒ self
Deletes series by 0-based indexes from the chart legend.
chart.legend_delete_series([0, 2])
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'ext/xlsxwriter/chart.c', line 219 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]; for (size_t i = 0; i < len; ++i) { series_arr[i] = NUM2INT(rb_check_to_int(rb_ary_entry(series, i))); } series_arr[len] = -1; struct chart *ptr; Data_Get_Struct(self, struct chart, ptr); chart_legend_delete_series(ptr->chart, 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}.
189 190 191 192 193 194 195 196 |
# File 'ext/xlsxwriter/chart.c', line 189 VALUE chart_legend_set_position_(VALUE self, VALUE pos) { struct chart *ptr; Data_Get_Struct(self, struct chart, ptr); chart_legend_set_position(ptr->chart, 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).
203 204 205 206 207 208 209 210 211 |
# File 'ext/xlsxwriter/chart.c', line 203 VALUE chart_legend_set_font_(VALUE self, VALUE opts) { struct chart *ptr; lxw_chart_font font = val_to_lxw_chart_font(opts); Data_Get_Struct(self, struct chart, ptr); chart_legend_set_font(ptr->chart, &font); return self; } |
#rotation=(rotation) ⇒ Object
:nodoc:
249 250 251 252 253 254 255 256 |
# File 'ext/xlsxwriter/chart.c', line 249 VALUE chart_set_rotation_(VALUE self, VALUE rotation) { struct chart *ptr; Data_Get_Struct(self, struct chart, ptr); chart_set_rotation(ptr->chart, NUM2UINT(rb_check_to_int(rotation))); return rotation; } |
#style=(style) ⇒ Object
Sets the chart style (integer from 1 to 48, default is 2).
239 240 241 242 243 244 245 246 |
# File 'ext/xlsxwriter/chart.c', line 239 VALUE chart_set_style_(VALUE self, VALUE style) { struct chart *ptr; Data_Get_Struct(self, struct chart, ptr); chart_set_style(ptr->chart, NUM2INT(rb_check_to_int(style))); return style; } |
#title=(title) ⇒ Object
Sets the chart title.
150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'ext/xlsxwriter/chart.c', line 150 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
132 133 134 135 |
# File 'ext/xlsxwriter/chart.c', line 132 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
141 142 143 144 |
# File 'ext/xlsxwriter/chart.c', line 141 VALUE chart_y_axis_(VALUE self) { return rb_funcall(cChartAxis, rb_intern("new"), 2, self, ID2SYM(rb_intern("y"))); } |