summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Veijola <[email protected]>2015-07-28 15:03:44 +0300
committerErik Veijola <[email protected]>2015-07-28 15:03:44 +0300
commite250b11d4f8172753f18c0edc152d614a6feaf2f (patch)
treeeb7c97bc28f90da5c093bcf574bca6b8739a0c67
parent1549f3fbacc72a7c091313860558114124962c81 (diff)
parent137dc0d94bd771893b88e22628331786cb0c56df (diff)
downloadcaxlsx-e250b11d4f8172753f18c0edc152d614a6feaf2f.tar.gz
caxlsx-e250b11d4f8172753f18c0edc152d614a6feaf2f.zip
Merge branch 'title_font_size'
-rw-r--r--lib/axlsx/drawing/chart.rb5
-rw-r--r--lib/axlsx/drawing/title.rb20
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index e7fcc9e8..de87b91a 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -128,6 +128,11 @@ module Axlsx
end
end
+ # The size of the Title object of the chart.
+ def title_size=(v)
+ @title.text_size = v unless v.to_s.empty?
+ end
+
# Show the legend in the chart
# @param [Boolean] v
# @return [Boolean]
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb
index 4e278689..7f2ff9f4 100644
--- a/lib/axlsx/drawing/title.rb
+++ b/lib/axlsx/drawing/title.rb
@@ -7,15 +7,24 @@ module Axlsx
# @return [String]
attr_reader :text
+ # Text size property
+ # @return [String]
+ attr_reader :text_size
+
# The cell that holds the text for the title. Setting this property will automatically update the text attribute.
# @return [Cell]
attr_reader :cell
# Creates a new Title object
# @param [String, Cell] title The cell or string to be used for the chart's title
- def initialize(title="")
+ def initialize(title="", title_size="")
self.cell = title if title.is_a?(Cell)
self.text = title.to_s unless title.is_a?(Cell)
+ if title_size.to_s.empty?
+ self.text_size = "1600"
+ else
+ self.text_size = title_size.to_s
+ end
end
# @see text
@@ -26,6 +35,14 @@ module Axlsx
v
end
+ # @see text_size
+ def text_size=(v)
+ DataTypeValidator.validate 'Title.text_size', String, v
+ @text_size = v
+ @cell = nil
+ v
+ end
+
# @see cell
def cell=(v)
DataTypeValidator.validate 'Title.text', Cell, v
@@ -62,6 +79,7 @@ module Axlsx
str << '<a:lstStyle/>'
str << '<a:p>'
str << '<a:r>'
+ str << ('<a:rPr sz="' << @text_size.to_s << '"/>')
str << ('<a:t>' << @text.to_s << '</a:t>')
str << '</a:r>'
str << '</a:p>'