From caf6f54acd0b9f1cfbe2e34bb759031e5c387bb8 Mon Sep 17 00:00:00 2001 From: Brad Stewart Date: Tue, 3 Mar 2015 15:56:25 -0600 Subject: Allow legend position to be set on charts --- lib/axlsx/drawing/chart.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 1d6b9293..fb96ed53 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -20,6 +20,7 @@ module Axlsx @graphic_frame.anchor.drawing.worksheet.workbook.charts << self @series = SimpleTypedList.new Series @show_legend = true + @legend_position = :r @display_blanks_as = :gap @series_type = Series @title = Title.new @@ -71,6 +72,17 @@ module Axlsx # @return [Boolean] attr_reader :show_legend + # Set the location of the chart's legend + # @return [Symbol] The position of this legend + # @note + # The following are allowed + # :b + # :l + # :r + # :t + # :tr + attr_reader :legend_position + # How to display blank values # Options are # * gap: Display nothing @@ -126,6 +138,11 @@ module Axlsx # @param [Integer] v must be between 1 and 48 def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end + # Set the position of the chart's legend. + # see ECMA Part 1 ยง21.2.2.196 + # @param [Symbol] v must be between 1 and 48 + def legend_position=(v) RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v; @legend_position = v; end + # backwards compatibility to allow chart.to and chart.from access to anchor markers # @note This will be disconinued in version 2.0.0. Please use the end_at method def to @@ -167,7 +184,7 @@ module Axlsx str << '' if @show_legend str << '' - str << '' + str << '' str << '' str << '' str << '' -- cgit v1.2.3