Class: Writexlsx::Chart::Area

Inherits:
Writexlsx::Chart show all
Includes:
Utility
Defined in:
lib/write_xlsx/chart/area.rb

Constant Summary

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary

Attributes inherited from Writexlsx::Chart

#embedded, #formula_data, #formula_ids, #id, #index, #name, #palette, #protection

Instance Method Summary collapse

Methods included from Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, delete_files, #ptrue?, #put_deprecate_message, #row_col_notation, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #write_color, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Methods inherited from Writexlsx::Chart

#add_series, #assemble_xml_file, factory, #set_chartarea, #set_embedded_config_data, #set_legend, #set_plotarea, #set_style, #set_title, #set_x2_axis, #set_x_axis, #set_xml_writer, #set_y2_axis, #set_y_axis, #show_blanks_as, #show_hidden_data, #write_bar_chart

Constructor Details

#initialize(subtype) ⇒ Area

Returns a new instance of Area.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/write_xlsx/chart/area.rb', line 23

def initialize(subtype)
  super(subtype)
  @subtype = subtype || 'standard'
  @cross_between = 'midCat'
  @show_crosses  = false

  # Override and reset the default axis values.
  if @subtype == 'percent_stacked'
    @y_axis[:_defaults][:num_format] = '0%'
  end

  set_y_axis
end

Instance Method Details

#write_area_chart(params) ⇒ Object

Write the <c:areaChart> element.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/write_xlsx/chart/area.rb', line 48

def write_area_chart(params)
  series = axes_series(params)
  return if series.empty?

  if @subtype == 'percent_stacked'
    subtype = 'percentStacked'
  else
    subtype = @subtype
  end
  @writer.tag_elements('c:areaChart') do
    # Write the c:grouping element.
    write_grouping(subtype)
    # Write the series elements.
    series.each {|s| write_series(s)}

    # Write the c:marker element.
    write_marker_value

    # Write the c:axId elements
    write_axis_ids(params)
  end
end

#write_chart_type(params) ⇒ Object

Override the virtual superclass method with a chart specific method.



40
41
42
43
# File 'lib/write_xlsx/chart/area.rb', line 40

def write_chart_type(params)
  # Write the c:areaChart element.
  write_area_chart(params)
end