Class: Writexlsx::Chart::Bar
- Inherits:
-
Writexlsx::Chart
- Object
- Writexlsx::Chart
- Writexlsx::Chart::Bar
- Includes:
- Utility::XmlPrimitives
- Defined in:
- lib/write_xlsx/chart/bar.rb
Constant Summary
Constants included from Utility::ChartFormatting
Utility::ChartFormatting::PATTERN_TYPES
Constants included from Utility::Common
Utility::Common::PERL_TRUE_VALUES
Instance Attribute Summary
Attributes inherited from Writexlsx::Chart
#already_inserted, #axis2_ids, #combined, #date_category, #embedded, #formula_data, #formula_ids, #height, #id, #index, #label_position_default, #label_positions, #name, #palette, #protection, #series_index, #width, #writer, #x2_axis, #x_offset, #x_scale, #y2_axis, #y_offset, #y_scale
Instance Method Summary collapse
-
#combine(chart) ⇒ Object
Override parent method to add an extra check that is required for Bar charts to ensure that their combined chart is on a secondary axis.
-
#initialize(subtype) ⇒ Bar
constructor
A new instance of Bar.
-
#write_bar_dir ⇒ Object
Write the <c:barDir> element.
-
#write_chart_type(params) ⇒ Object
Override the virtual superclass method with a chart specific method.
-
#write_err_dir(direction) ⇒ Object
Write the <c:errDir> element.
Methods included from Utility::XmlPrimitives
#r_id_attributes, #write_color, #write_xml_declaration, #xml_str
Methods inherited from Writexlsx::Chart
#already_inserted?, factory, #is_secondary?, #set_xml_writer, #write_bar_chart
Methods included from AxisWriter
Methods included from XmlWriter
Methods included from SeriesData
Methods included from Settings
#add_series, #set_chartarea, #set_drop_lines, #set_embedded_config_data, #set_high_low_lines, #set_legend, #set_plotarea, #set_size, #set_style, #set_table, #set_title, #set_up_down_bars, #set_x2_axis, #set_x_axis, #set_y2_axis, #set_y_axis, #show_blanks_as, #show_hidden_data, #show_na_as_empty_cell
Methods included from Gradient
Methods included from Utility::RichText
#convert_font_args, #get_font_latin_attributes, #get_font_style_attributes, #params_to_font, #underline_attributes, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_def_rpr_r_pr_common, #write_tx_pr
Methods included from Utility::ChartFormatting
#color, #dash_types, #fill_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color_from_index, #pattern_properties, #value_or_raise, #write_a_solid_fill, #write_a_srgb_clr
Methods included from Utility::Common
#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message
Constructor Details
#initialize(subtype) ⇒ Bar
Returns a new instance of Bar.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/write_xlsx/chart/bar.rb', line 24 def initialize(subtype) super @subtype = subtype || 'clustered' @cat_axis_position = 'l' @val_axis_position = 'b' @horiz_val_axis = 0 @horiz_cat_axis = 1 @show_crosses = false # Override and reset the default axis values. axis_defaults_set set_x_axis set_y_axis # Set the available data label positions for this chart type. @label_position_default = 'outside_end' @label_positions = { 'center' => 'ctr', 'inside_base' => 'inBase', 'inside_end' => 'inEnd', 'outside_end' => 'outEnd' } end |
Instance Method Details
#combine(chart) ⇒ Object
Override parent method to add an extra check that is required for Bar charts to ensure that their combined chart is on a secondary axis.
51 52 53 54 55 |
# File 'lib/write_xlsx/chart/bar.rb', line 51 def combine(chart) raise 'Charts combined with Bar charts must be on a secondary axis' unless chart.is_secondary? super end |
#write_bar_dir ⇒ Object
Write the <c:barDir> element.
74 75 76 |
# File 'lib/write_xlsx/chart/bar.rb', line 74 def @writer.empty_tag('c:barDir', [%w[val bar]]) end |
#write_chart_type(params) ⇒ Object
Override the virtual superclass method with a chart specific method.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/write_xlsx/chart/bar.rb', line 60 def write_chart_type(params) if params[:primary_axes] != 0 # Reverse X and Y axes for Bar charts. @y_axis, @x_axis = @x_axis, @y_axis @y2_axis.position = 't' if @y2_axis.position == 'r' end # Write the c:barChart element. (params) end |
#write_err_dir(direction) ⇒ Object
Write the <c:errDir> element. Overridden from Chart class since it is not used in Bar charts.
82 83 84 |
# File 'lib/write_xlsx/chart/bar.rb', line 82 def write_err_dir(direction) # do nothing end |