Class: Writexlsx::Chart
- Inherits:
-
Object
- Object
- Writexlsx::Chart
- Includes:
- AxisWriter, FormattingWriter, Initialization, SeriesData, SeriesWriter, Settings, XmlWriter, Gradient, Utility::ChartFormatting, Utility::Common, Utility::RichText
- Defined in:
- lib/write_xlsx/chart.rb,
lib/write_xlsx/chart/bar.rb,
lib/write_xlsx/chart/pie.rb,
lib/write_xlsx/chart/area.rb,
lib/write_xlsx/chart/axis.rb,
lib/write_xlsx/chart/line.rb,
lib/write_xlsx/chart/radar.rb,
lib/write_xlsx/chart/stock.rb,
lib/write_xlsx/chart/table.rb,
lib/write_xlsx/chart/column.rb,
lib/write_xlsx/chart/legend.rb,
lib/write_xlsx/chart/series.rb,
lib/write_xlsx/chart/caption.rb,
lib/write_xlsx/chart/scatter.rb,
lib/write_xlsx/chart/doughnut.rb,
lib/write_xlsx/chart/settings.rb,
lib/write_xlsx/chart/chart_area.rb,
lib/write_xlsx/chart/xml_writer.rb,
lib/write_xlsx/chart/axis_writer.rb,
lib/write_xlsx/chart/series_data.rb,
lib/write_xlsx/chart/series_writer.rb,
lib/write_xlsx/chart/initialization.rb,
lib/write_xlsx/chart/d_pt_point_writer.rb,
lib/write_xlsx/chart/formatting_writer.rb
Defined Under Namespace
Modules: AxisWriter, DPtPointWriter, FormattingWriter, Initialization, SeriesData, SeriesWriter, Settings, XmlWriter Classes: Area, Axis, Bar, Caption, ChartArea, Chartline, Column, Doughnut, Errorbars, Gridline, Legend, Line, Marker, Pie, Point, Radar, Scatter, Series, Stock, Table, Trendline
Constant Summary
Constants included from Utility::ChartFormatting
Utility::ChartFormatting::PATTERN_TYPES
Constants included from Utility::Common
Utility::Common::PERL_TRUE_VALUES
Instance Attribute Summary collapse
-
#already_inserted ⇒ Object
writeonly
:nodoc:.
-
#axis2_ids ⇒ Object
readonly
:nodoc:.
-
#combined ⇒ Object
readonly
:nodoc:.
-
#date_category ⇒ Object
writeonly
:nodoc:.
-
#embedded ⇒ Object
readonly
:nodoc:.
-
#formula_data ⇒ Object
readonly
:nodoc:.
-
#formula_ids ⇒ Object
readonly
:nodoc:.
-
#height ⇒ Object
readonly
:nodoc:.
-
#id ⇒ Object
:nodoc:.
-
#index ⇒ Object
writeonly
:nodoc:.
-
#label_position_default ⇒ Object
readonly
:nodoc:.
-
#label_positions ⇒ Object
readonly
:nodoc:.
-
#name ⇒ Object
:nodoc:.
-
#palette ⇒ Object
writeonly
:nodoc:.
-
#protection ⇒ Object
writeonly
:nodoc:.
-
#series_index ⇒ Object
writeonly
:nodoc:.
-
#width ⇒ Object
readonly
:nodoc:.
-
#writer ⇒ Object
writeonly
:nodoc:.
-
#x2_axis ⇒ Object
readonly
:nodoc:.
-
#x_offset ⇒ Object
readonly
:nodoc:.
-
#x_scale ⇒ Object
readonly
:nodoc:.
-
#y2_axis ⇒ Object
readonly
:nodoc:.
-
#y_offset ⇒ Object
readonly
:nodoc:.
-
#y_scale ⇒ Object
readonly
:nodoc:.
Class Method Summary collapse
-
.factory(current_subclass, subtype = nil) ⇒ Object
Factory method for returning chart objects based on their class type.
Instance Method Summary collapse
-
#already_inserted? ⇒ Boolean
Public chart state.
-
#initialize(subtype) ⇒ Chart
constructor
:nodoc:.
- #is_secondary? ⇒ Boolean
-
#set_xml_writer(filename) ⇒ Object
:nodoc:.
-
#write_bar_chart(params) ⇒ Object
Write the <c:barChart> element.
Methods included from AxisWriter
Methods included from XmlWriter
Methods included from SeriesData
Methods included from Settings
#add_series, #combine, #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) ⇒ Chart
:nodoc:
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/write_xlsx/chart.rb', line 108 def initialize(subtype) # :nodoc: @writer = Package::XMLWriterSimple.new @subtype = subtype @sheet_type = 0x0200 @series = [] @embedded = false @id = -1 @series_index = 0 @style_id = 2 @formula_ids = {} @formula_data = [] @protection = 0 @chartarea = ChartArea.new @plotarea = ChartArea.new @title = Caption.new(self) @name = '' @table = nil set_default_properties @combined = nil @is_secondary = false end |
Instance Attribute Details
#already_inserted=(value) ⇒ Object (writeonly)
:nodoc:
62 63 64 |
# File 'lib/write_xlsx/chart.rb', line 62 def already_inserted=(value) @already_inserted = value end |
#axis2_ids ⇒ Object (readonly)
:nodoc:
65 66 67 |
# File 'lib/write_xlsx/chart.rb', line 65 def axis2_ids @axis2_ids end |
#combined ⇒ Object (readonly)
:nodoc:
61 62 63 |
# File 'lib/write_xlsx/chart.rb', line 61 def combined @combined end |
#date_category=(value) ⇒ Object (writeonly)
:nodoc:
62 63 64 |
# File 'lib/write_xlsx/chart.rb', line 62 def date_category=(value) @date_category = value end |
#embedded ⇒ Object (readonly)
:nodoc:
58 59 60 |
# File 'lib/write_xlsx/chart.rb', line 58 def @embedded end |
#formula_data ⇒ Object (readonly)
:nodoc:
58 59 60 |
# File 'lib/write_xlsx/chart.rb', line 58 def formula_data @formula_data end |
#formula_ids ⇒ Object (readonly)
:nodoc:
58 59 60 |
# File 'lib/write_xlsx/chart.rb', line 58 def formula_ids @formula_ids end |
#height ⇒ Object (readonly)
:nodoc:
60 61 62 |
# File 'lib/write_xlsx/chart.rb', line 60 def height @height end |
#id ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/write_xlsx/chart.rb', line 56 def id @id end |
#index=(value) ⇒ Object (writeonly)
:nodoc:
57 58 59 |
# File 'lib/write_xlsx/chart.rb', line 57 def index=(value) @index = value end |
#label_position_default ⇒ Object (readonly)
:nodoc:
61 62 63 |
# File 'lib/write_xlsx/chart.rb', line 61 def label_position_default @label_position_default end |
#label_positions ⇒ Object (readonly)
:nodoc:
61 62 63 |
# File 'lib/write_xlsx/chart.rb', line 61 def label_positions @label_positions end |
#name ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/write_xlsx/chart.rb', line 56 def name @name end |
#palette=(value) ⇒ Object (writeonly)
:nodoc:
57 58 59 |
# File 'lib/write_xlsx/chart.rb', line 57 def palette=(value) @palette = value end |
#protection=(value) ⇒ Object (writeonly)
:nodoc:
57 58 59 |
# File 'lib/write_xlsx/chart.rb', line 57 def protection=(value) @protection = value end |
#series_index=(value) ⇒ Object (writeonly)
:nodoc:
63 64 65 |
# File 'lib/write_xlsx/chart.rb', line 63 def series_index=(value) @series_index = value end |
#width ⇒ Object (readonly)
:nodoc:
60 61 62 |
# File 'lib/write_xlsx/chart.rb', line 60 def width @width end |
#writer=(value) ⇒ Object (writeonly)
:nodoc:
64 65 66 |
# File 'lib/write_xlsx/chart.rb', line 64 def writer=(value) @writer = value end |
#x2_axis ⇒ Object (readonly)
:nodoc:
65 66 67 |
# File 'lib/write_xlsx/chart.rb', line 65 def x2_axis @x2_axis end |
#x_offset ⇒ Object (readonly)
:nodoc:
59 60 61 |
# File 'lib/write_xlsx/chart.rb', line 59 def x_offset @x_offset end |
#x_scale ⇒ Object (readonly)
:nodoc:
59 60 61 |
# File 'lib/write_xlsx/chart.rb', line 59 def x_scale @x_scale end |
#y2_axis ⇒ Object (readonly)
:nodoc:
65 66 67 |
# File 'lib/write_xlsx/chart.rb', line 65 def y2_axis @y2_axis end |
#y_offset ⇒ Object (readonly)
:nodoc:
59 60 61 |
# File 'lib/write_xlsx/chart.rb', line 59 def y_offset @y_offset end |
#y_scale ⇒ Object (readonly)
:nodoc:
59 60 61 |
# File 'lib/write_xlsx/chart.rb', line 59 def y_scale @y_scale end |
Class Method Details
.factory(current_subclass, subtype = nil) ⇒ Object
Factory method for returning chart objects based on their class type.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/write_xlsx/chart.rb', line 76 def self.factory(current_subclass, subtype = nil) # :nodoc: case current_subclass.downcase.capitalize when 'Area' require 'write_xlsx/chart/area' Chart::Area.new(subtype) when 'Bar' require 'write_xlsx/chart/bar' Chart::Bar.new(subtype) when 'Column' require 'write_xlsx/chart/column' Chart::Column.new(subtype) when 'Doughnut' require 'write_xlsx/chart/doughnut' Chart::Doughnut.new(subtype) when 'Line' require 'write_xlsx/chart/line' Chart::Line.new(subtype) when 'Pie' require 'write_xlsx/chart/pie' Chart::Pie.new(subtype) when 'Radar' require 'write_xlsx/chart/radar' Chart::Radar.new(subtype) when 'Scatter' require 'write_xlsx/chart/scatter' Chart::Scatter.new(subtype) when 'Stock' require 'write_xlsx/chart/stock' Chart::Stock.new(subtype) end end |
Instance Method Details
#already_inserted? ⇒ Boolean
Public chart state
195 196 197 |
# File 'lib/write_xlsx/chart.rb', line 195 def already_inserted? @already_inserted end |
#is_secondary? ⇒ Boolean
199 200 201 |
# File 'lib/write_xlsx/chart.rb', line 199 def is_secondary? @is_secondary end |
#set_xml_writer(filename) ⇒ Object
:nodoc:
131 132 133 |
# File 'lib/write_xlsx/chart.rb', line 131 def set_xml_writer(filename) # :nodoc: @writer.set_xml_writer(filename) end |
#write_bar_chart(params) ⇒ Object
Write the <c:barChart> element.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/write_xlsx/chart.rb', line 144 def (params) # :nodoc: series = if ptrue?(params[:primary_axes]) get_primary_axes_series else get_secondary_axes_series end return if series.empty? subtype = @subtype subtype = 'percentStacked' if subtype == 'percent_stacked' # Set a default overlap for stacked charts. @series_overlap_1 = 100 if @subtype =~ /stacked/ && !@series_overlap_1 @writer.tag_elements('c:barChart') do # Write the c:barDir element. # Write the c:grouping element. write_grouping(subtype) # Write the c:ser elements. series.each { |s| write_ser(s) } # write the c:marker element. write_marker_value if ptrue?(params[:primary_axes]) # Write the c:gapWidth element. write_gap_width(@series_gap_1) # Write the c:overlap element. write_overlap(@series_overlap_1) else # Write the c:gapWidth element. write_gap_width(@series_gap_2) # Write the c:overlap element. write_overlap(@series_overlap_2) end # write the c:overlap element. write_overlap(@series_overlap) # Write the c:axId elements write_axis_ids(params) end end |