Class: Axlsx::DataBar

Inherits:
Object
  • Object
show all
Includes:
OptionsParser, SerializedAttributes
Defined in:
lib/axlsx/workbook/worksheet/data_bar.rb

Overview

Note:

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

Instance Method Summary collapse

Methods included from SerializedAttributes

included, #serialized_attributes

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ DataBar

Creates a new data bar conditional formatting object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • minLength (Integer)
  • maxLength (Integer)
  • showValue (Boolean)
  • color (String)
    • the rbg value used to color the bars

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
24
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 18

def initialize(options = {})
  @min_length = 10
  @max_length = 90
  @show_value = true
  parse_options options
  yield self if block_given?
end

Instance Attribute Details

#max_lengthInteger 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

Returns:

  • (Integer)


42
43
44
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 42

def max_length
  @max_length
end

#min_lengthInteger 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

Returns:

  • (Integer)


35
36
37
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 35

def min_length
  @min_length
end

#show_valueBoolean 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

Returns:

  • (Boolean)


49
50
51
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 49

def show_value
  @show_value
end

Instance Method Details

#colorColor

color the color object used in the data bar formatting

Returns:



62
63
64
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 62

def color
  @color ||= Color.new :rgb => "FF0000FF"
end

#color=(v) ⇒ Object

Sets the color for the data bars.

Parameters:

  • v (Color|String)

    The color object, or rgb string value to apply



89
90
91
92
93
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 89

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

Parameters:

  • str (String) (defaults to: "")

Returns:

  • (String)


98
99
100
101
102
103
104
105
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 98

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

#value_objectsSimpleTypedList

A simple typed list of cfvos

Returns:

  • (SimpleTypedList)

See Also:



55
56
57
# File 'lib/axlsx/workbook/worksheet/data_bar.rb', line 55

def value_objects
  @value_objects ||= Cfvos.new
end