diff options
| author | Koza <[email protected]> | 2023-05-31 10:23:28 +0200 |
|---|---|---|
| committer | Koza <[email protected]> | 2023-10-19 10:17:14 +0200 |
| commit | 86393121fdd30dacf5b54eb64ac30be493405376 (patch) | |
| tree | 4a25cd2dd3a77afae53d0068f9ef27084c868171 /lib | |
| parent | e15ceb41bbcbdbeed33e304101cc66114ef1cf7d (diff) | |
| download | caxlsx-86393121fdd30dacf5b54eb64ac30be493405376.tar.gz caxlsx-86393121fdd30dacf5b54eb64ac30be493405376.zip | |
Add optional interpolation points to icon sets
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/icon_set.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/axlsx/workbook/worksheet/icon_set.rb b/lib/axlsx/workbook/worksheet/icon_set.rb index 64b0c21a..e5dbcb11 100644 --- a/lib/axlsx/workbook/worksheet/icon_set.rb +++ b/lib/axlsx/workbook/worksheet/icon_set.rb @@ -20,8 +20,10 @@ module Axlsx @percent = @showValue = true @reverse = false @iconSet = "3TrafficLights1" - initialize_value_objects + @interpolationPoints = [0, 33, 67] + parse_options options + yield self if block_given? end @@ -34,7 +36,7 @@ module Axlsx attr_reader :iconSet # Indicates whether the thresholds indicate percentile values, instead of number values. - # The default falue is true + # The default value is true # @return [Boolean] attr_reader :percent @@ -48,9 +50,21 @@ module Axlsx # @return [Boolean] attr_reader :showValue + # Sets the values of the interpolation points in the scale. + # The default value is [0, 33, 67] + # @return [Integer] + attr_reader :interpolationPoints + # @see iconSet def iconSet=(v); Axlsx.validate_icon_set(v); @iconSet = v end + # @see interpolationPoints + def interpolationPoints=(v) + v.each { |point| Axlsx.validate_int(point) } + @value_objects = nil + @interpolationPoints = v + end + # @see showValue def showValue=(v); Axlsx.validate_boolean(v); @showValue = v end @@ -64,6 +78,8 @@ module Axlsx # @param [String] str # @return [String] def to_xml_string(str = +'') + initialize_value_objects if @value_objects.nil? + serialized_tag('iconSet', str) do @value_objects.each { |cfvo| cfvo.to_xml_string(str) } end @@ -72,10 +88,9 @@ module Axlsx private # Initalize the simple typed list of value objects - # I am keeping this private for now as I am not sure what impact changes to the required two cfvo objects will do. def initialize_value_objects @value_objects = SimpleTypedList.new Cfvo - @value_objects.concat [Cfvo.new(type: :percent, val: 0), Cfvo.new(type: :percent, val: 33), Cfvo.new(type: :percent, val: 67)] + @interpolationPoints.each { |point| @value_objects << Cfvo.new(type: :percent, val: point) } @value_objects.lock end end |
