Class: Axlsx::DataBar
- Inherits:
-
Object
- Object
- Axlsx::DataBar
- Includes:
- OptionsParser, SerializedAttributes
- 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
-
#max_length ⇒ Integer
(also: #maxLength)
maxLength attribute The maximum length of the data bar, as a percentage of the cell width.
-
#min_length ⇒ Integer
(also: #minLength)
minLength attribute The minimum length of the data bar, as a percentage of the cell width.
-
#show_value ⇒ Boolean
(also: #showValue)
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied.
Class Method Summary collapse
-
.default_cfvos ⇒ Object
This differs from ColorScale.
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 = {}, *cfvos) {|_self| ... } ⇒ DataBar
constructor
Creates a new data bar conditional formatting object.
-
#to_xml_string(str = "") ⇒ String
Serialize this object to an xml string.
-
#value_objects ⇒ SimpleTypedList
A simple typed list of cfvos.
Methods included from SerializedAttributes
#declared_attributes, included, #serialized_attributes, #serialized_element_attributes
Methods included from OptionsParser
Constructor Details
#initialize(options = {}, *cfvos) {|_self| ... } ⇒ DataBar
Creates a new data bar conditional formatting object
28 29 30 31 32 33 34 35 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 28 def initialize( = {}, *cfvos) @min_length = 10 @max_length = 90 @show_value = true initialize_cfvos(cfvos) yield self if block_given? end |
Instance Attribute Details
#max_length ⇒ Integer Also known as: maxLength
maxLength attribute The maximum length of the data bar, as a percentage of the cell width. The default value is 90
53 54 55 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 53 def max_length @max_length end |
#min_length ⇒ Integer Also known as: minLength
minLength attribute The minimum length of the data bar, as a percentage of the cell width. The default value is 10
46 47 48 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 46 def min_length @min_length end |
#show_value ⇒ Boolean Also known as: showValue
maxLength attribute Indicates whether to show the values of the cells on which this data bar is applied. The default value is true
60 61 62 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 60 def show_value @show_value end |
Class Method Details
.default_cfvos ⇒ Object
This differs from ColorScale. There must be exactly two cfvos one color
15 16 17 18 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 15 def default_cfvos [{:type => :min, :val => "0"}, {:type => :max, :val => "0"}] end |
Instance Method Details
#color ⇒ Color
color the color object used in the data bar formatting
73 74 75 |
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 73 def color @color ||= Color.new :rgb => "FF0000FF" end |
#color=(v) ⇒ Object
Sets the color for the data bars.
100 101 102 103 104 |
# 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 |
#to_xml_string(str = "") ⇒ String
Serialize this object to an xml string
109 110 111 112 113 114 115 116 |
# 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 |