class Axlsx::DataBar
@note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
@see Worksheet#add_conditional_formatting
@see ConditionalFormattingRule#initialize
Constants
- CHILD_ELEMENTS
instance values that must be serialized as their own elements - e.g. not attributes.
Attributes
maxLength attribute The maximum length of the data bar, as a percentage of the cell width. The default value is 90 @return [Integer]
maxLength attribute The maximum length of the data bar, as a percentage of the cell width. The default value is 90 @return [Integer]
minLength attribute The minimum length of the data bar, as a percentage of the cell width. The default value is 10 @return [Integer]
minLength attribute The minimum length of the data bar, as a percentage of the cell width. The default value is 10 @return [Integer]
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied. The default value is true @return [Boolean]
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied. The default value is true @return [Boolean]
Public Class Methods
This differs from ColorScale
. There must be exactly two cfvos one color
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 15 def default_cfvos [{:type => :min, :val => "0"}, {:type => :max, :val => "0"}] end
Creates a new data bar conditional formatting object @param [Hash] options @option options [Integer] minLength @option options [Integer] maxLength @option options [Boolean] showValue @option options [String] color - the rbg value used to color the bars @param [Array] cfvos hashes defining the gradient interpolation points for this formatting.
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 28 def initialize(options = {}, *cfvos) @min_length = 10 @max_length = 90 @show_value = true parse_options options initialize_cfvos(cfvos) yield self if block_given? end
Public Instance Methods
color the color object used in the data bar formatting @return [Color]
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 73 def color @color ||= Color.new :rgb => "FF0000FF" end
Sets the color for the data bars. @param [Color|String] v The color object, or rgb string value to apply
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 100 def color=(v) @color = v if v.is_a? Color self.color.rgb = v if v.is_a? String @color end
@see maxLength
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 85 def max_length=(v) Axlsx.validate_unsigned_int(v) @max_length = v end
@see minLength
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 78 def min_length=(v) Axlsx.validate_unsigned_int(v) @min_length = v end
@see showValue
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 92 def show_value=(v) Axlsx.validate_boolean(v) @show_value = v end
Serialize this object to an xml string @param [String] str @return [String]
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 109 def to_xml_string(str="") str << '<dataBar ' serialized_attributes str str << '>' value_objects.to_xml_string(str) self.color.to_xml_string(str) str << '</dataBar>' end
A simple typed list of cfvos @return [SimpleTypedList] @see Cfvo
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 66 def value_objects @value_objects ||= Cfvos.new end
Private Instance Methods
# File lib/axlsx/workbook/worksheet/data_bar.rb, line 120 def initialize_cfvos(cfvos) self.class.default_cfvos.each_with_index.map do |default, index| if index < cfvos.size value_objects << Cfvo.new(default.merge(cfvos[index])) else value_objects << Cfvo.new(default) end end end