summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorStefan <[email protected]>2022-05-23 12:52:53 +0200
committerStefan Daschek <[email protected]>2022-06-01 09:55:27 +0200
commit35ed793586a57837b2e0319e57b5c763f9f4ade4 (patch)
tree46fe4d8701c12e5a66f7fdf40aac7e504d9411bf /lib
parent2a5c58faffb690831911f3799e8c097c6fdef793 (diff)
downloadcaxlsx-35ed793586a57837b2e0319e57b5c763f9f4ade4.tar.gz
caxlsx-35ed793586a57837b2e0319e57b5c763f9f4ade4.zip
Implement “plot visible only” setting for charts
Until now this setting was hardcoded to `true`. The setting affects whether data from hidden cells (cells width zero height or width) is used when plotting the chart.
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/drawing/chart.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index 99b62b64..723c79d8 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -14,6 +14,7 @@ module Axlsx
# @option options [Symbol] legend_position
# @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart.
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
+ # @option options [Boolean] plot_visible_only (true) Whether only data from visible cells should be plotted.
def initialize(frame, options={})
@style = 18
@view_3D = nil
@@ -26,6 +27,7 @@ module Axlsx
@series_type = Series
@title = Title.new
@bg_color = nil
+ @plot_visible_only = true
parse_options options
start_at(*options[:start_at]) if options[:start_at]
end_at(*options[:end_at]) if options[:end_at]
@@ -98,6 +100,10 @@ module Axlsx
# @return [String]
attr_reader :bg_color
+ # Whether only data from visible cells should be plotted.
+ # @return [Boolean]
+ attr_reader :plot_visible_only
+
# The relationship object for this chart.
# @return [Relationship]
def relationship
@@ -180,6 +186,11 @@ module Axlsx
@bg_color = v
end
+ # Whether only data from visible cells should be plotted.
+ # @param [Boolean] v
+ # @return [Boolean]
+ def plot_visible_only=(v) Axlsx::validate_boolean(v); @plot_visible_only = v; end
+
# Serializes the object
# @param [String] str
# @return [String]
@@ -206,7 +217,7 @@ module Axlsx
str << '<c:overlay val="0"/>'
str << '</c:legend>'
end
- str << '<c:plotVisOnly val="1"/>'
+ str << ('<c:plotVisOnly val="' << @plot_visible_only.to_s << '"/>')
str << ('<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>')
str << '<c:showDLblsOverMax val="1"/>'
str << '</c:chart>'