Class: Writexlsx::Chart::Stock
- Inherits:
-
Writexlsx::Chart
- Object
- Writexlsx::Chart
- Writexlsx::Chart::Stock
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/chart/stock.rb
Overview
The default Stock chart is an High-Low-Close chart. A series must be added for each of these data sources.
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, #palette
Instance Method Summary collapse
-
#initialize ⇒ Stock
constructor
A new instance of Stock.
-
#modify_series_formatting ⇒ Object
Add default formatting to the series data.
-
#write_chart_type ⇒ Object
Override the virtual superclass method with a chart specific method.
-
#write_plot_area ⇒ Object
Write the <c:plotArea> element.
-
#write_series ⇒ Object
Over-ridden to add hi_low_lines().
-
#write_stock_chart ⇒ Object
Write the <c:stockChart> element.
Methods included from Utility
#absolute_char, delete_files, #put_deprecate_message, #substitute_cellref, #underline_attributes, #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_x_axis, #set_xml_writer, #set_y_axis, #write_bar_chart
Constructor Details
#initialize ⇒ Stock
Returns a new instance of Stock.
27 28 29 |
# File 'lib/write_xlsx/chart/stock.rb', line 27 def initialize super(self.class) end |
Instance Method Details
#modify_series_formatting ⇒ Object
Add default formatting to the series data.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/write_xlsx/chart/stock.rb', line 99 def modify_series_formatting index = 0 array = [] @series.each do |series| if index % 4 != 3 if series[:_line][:_defined].nil? || series[:_line][:_defined] == 0 series[:_line] = { :width => 2.25, :none => 1, :_defined => 1 } end if series[:_marker].nil? || series[:_marker] == 0 if index % 4 == 2 series[:_marker] = { :type => 'dot', :size => 3 } else series[:_marker] = { :type => 'none' } end end end index += 1 array << series end @series = array end |
#write_chart_type ⇒ Object
Override the virtual superclass method with a chart specific method.
34 35 36 37 |
# File 'lib/write_xlsx/chart/stock.rb', line 34 def write_chart_type # Write the c:areaChart element. write_stock_chart end |
#write_plot_area ⇒ Object
Write the <c:plotArea> element.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/write_xlsx/chart/stock.rb', line 83 def write_plot_area @writer.tag_elements('c:plotArea') do # Write the c:layout element. write_layout # Write the subclass chart type element. write_chart_type # Write the c:dateAx element. write_date_axis # Write the c:catAx element. write_val_axis end end |
#write_series ⇒ Object
Over-ridden to add hi_low_lines(). TODO. Refactor up into the SUPER class.
Write the series elements.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/write_xlsx/chart/stock.rb', line 57 def write_series # Write each series with subelements. index = 0 @series.each do |series| write_ser(index, series) index += 1 end # Write the c:hiLowLines element. write_hi_low_lines # Write the c:marker element. write_marker_value # Generate the axis ids. add_axis_id add_axis_id # Write the c:axId element. write_axis_id(@axis_ids[0]) write_axis_id(@axis_ids[1]) end |
#write_stock_chart ⇒ Object
Write the <c:stockChart> element.
42 43 44 45 46 47 48 49 50 |
# File 'lib/write_xlsx/chart/stock.rb', line 42 def write_stock_chart # Add default formatting to the series data. modify_series_formatting @writer.tag_elements('c:stockChart') do # Write the series elements. write_series end end |