Class: Axlsx::DataBar
- Inherits:
-
Object
- Object
- Axlsx::DataBar
- Defined in:
- lib/axlsx/workbook/worksheet/data_bar.rb
Overview
The recommended way to manage these rules is via Worksheet#add_conditional_formatting
Constant Summary collapse
- CHILD_ELEMENTS =
instance values that must be serialized as their own elements - e.g. not attributes.
[:value_objects, :color]
Instance Attribute Summary collapse
-
#maxLength ⇒ Integer
maxLength attribute The maximum length of the data bar, as a percentage of the cell width.
-
#minLength ⇒ Integer
minLength attribute The minimum length of the data bar, as a percentage of the cell width.
-
#showValue ⇒ Boolean
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied.
-
#value_objects ⇒ SimpleTypedList
readonly
A simple typed list of cfvos.
Instance Method Summary collapse
-
#color ⇒ Color
color the color object used in the data bar formatting.
-
#color=(v) ⇒ Object
Sets the color for the data bars.
-
#initialize(options = {}) {|_self| ... } ⇒ DataBar
constructor
Creates a new data bar conditional formatting object.
-
#to_xml_string(str = "") ⇒ String
Serialize this object to an xml string.
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ DataBar
Creates a new data bar conditional formatting object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 48 def initialize( = {}) @minLength = 10 @maxLength = 90 @showValue = true initialize_value_objects .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end yield self if block_given? end |
Instance Attribute Details
#maxLength ⇒ Integer
maxLength attribute The maximum length of the data bar, as a percentage of the cell width. The default value is 90
23 24 25 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 23 def maxLength @maxLength end |
#minLength ⇒ Integer
minLength attribute The minimum length of the data bar, as a percentage of the cell width. The default value is 10
17 18 19 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 17 def minLength @minLength end |
#showValue ⇒ Boolean
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied. The default value is true
29 30 31 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 29 def showValue @showValue end |
#value_objects ⇒ SimpleTypedList (readonly)
A simple typed list of cfvos
34 35 36 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 34 def value_objects @value_objects end |
Instance Method Details
#color ⇒ Color
color the color object used in the data bar formatting
39 40 41 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 39 def color @color ||= Color.new :rgb => "FF0000FF" end |
#color=(v) ⇒ Object
Sets the color for the data bars.
69 70 71 72 73 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 69 def color=(v) @color = v if v.is_a? Color self.color.rgb = v if v.is_a? String @color end |
#to_xml_string(str = "") ⇒ String
Serialize this object to an xml string
78 79 80 81 82 83 84 85 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 78 def to_xml_string(str="") str << '<dataBar ' str << instance_values.map { |key, value| '' << key << '="' << value.to_s << '"' unless CHILD_ELEMENTS.include?(key.to_sym) }.join(' ') str << '>' @value_objects.each { |cfvo| cfvo.to_xml_string(str) } self.color.to_xml_string(str) str << '</dataBar>' end |