From 4d16bfc43780e5d3f7368625700b583e3e98217a Mon Sep 17 00:00:00 2001
From: Randy Morgan Worksheet#add_chart is the recommended way to create charts for your
-worksheets.
+Worksheet#add_chart is the recommended way to create charts for your
+worksheets.
+ A Chart is the superclass for specific charts
+A Chart is the superclass for specific charts
+
A reference to the graphic frame that owns this chart.
++A reference to the graphic frame that owns this chart. +
A collection of series objects that are applied to the chart.
++A collection of series objects that are applied to the chart. +
The type of series to use for this chart.
++The type of series to use for this chart. +
Show the legend in the chart.
++Show the legend in the chart. +
The style for the chart.
++The style for the chart. +
The title object for the chart.
++The title object for the chart. +
The 3D view properties for the chart.
++The 3D view properties for the chart. +
Adds a new series to the chart's series collection.
++Adds a new series to the chart’s series collection. +
This is a short cut method to set the end anchor position If you need finer -granularity in positioning use graphic_frame.anchor.to.colOff / rowOff.
++This is a short cut method to set the end anchor position If you need finer +granularity in positioning use graphic_frame.anchor.to.colOff / rowOff. +
backwards compatibility to allow chart.to and chart.from access to anchor -markers.
++backwards compatibility to allow chart.to and chart.from access to anchor +markers. +
The index of this chart in the workbooks charts collection.
++The index of this chart in the workbooks charts collection. +
Creates a new chart object.
++Creates a new chart object. +
The part name for this chart.
++The part name for this chart. +
This is a short cut method to set the start anchor position If you need
+
+This is a short cut method to set the start anchor position If you need
finer granularity in positioning use graphic_frame.anchor.from.colOff /
-rowOff.
backwards compatibility to allow chart.to and chart.from access to anchor -markers.
++backwards compatibility to allow chart.to and chart.from access to anchor +markers. +
Chart Serialization serializes the chart.
++Chart Serialization serializes the chart. +
Creates a new chart object
++Creates a new chart object +
The frame that holds this chart.
++The frame that holds this chart. +
a customizable set of options
++a customizable set of options +
the object that the method was called on
++the object that the method was called on +
# File 'lib/axlsx/drawing/chart.rb', line 44 -def initialize(frame, ={}) - @style = 2 - @graphic_frame=frame - @graphic_frame.anchor.drawing.worksheet.workbook.charts << self - @series = SimpleTypedList.new Series - @show_legend = true - @series_type = Series - .each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end - start_at(*[:start_at]) if [:start_at] - end_at(*[:end_at]) if [:start_at] - yield self if block_given? -end+def initialize(frame, ={}) + @style = 2 + @graphic_frame=frame + @graphic_frame.anchor.drawing.worksheet.workbook.charts << self + @series = SimpleTypedList.new Series + @show_legend = true + @series_type = Series + .each do |o| + self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" + end + start_at(*[:start_at]) if [:start_at] + end_at(*[:end_at]) if [:start_at] + yield self if block_given? +end +
A reference to the graphic frame that owns this chart
++A reference to the graphic frame that owns this chart +
# File 'lib/axlsx/drawing/chart.rb', line 14 -def graphic_frame - @graphic_frame -end+def graphic_frame + @graphic_frame +end +
A collection of series objects that are applied to the chart
++A collection of series objects that are applied to the chart +
# File 'lib/axlsx/drawing/chart.rb', line 18 -def series - @series -end+def series + @series +end +
The type of series to use for this chart.
++The type of series to use for this chart. +
# File 'lib/axlsx/drawing/chart.rb', line 22 -def series_type - @series_type -end+def series_type + @series_type +end +
Show the legend in the chart
++Show the legend in the chart +
# File 'lib/axlsx/drawing/chart.rb', line 38 -def show_legend - @show_legend -end+def show_legend + @show_legend +end +
The style for the chart. see ECMA Part 1 §21.2.2.196
++The style for the chart. see ECMA Part 1 §21.2.2.196 +
# File 'lib/axlsx/drawing/chart.rb', line 34 -def style - @style -end+def style + @style +end +
The title object for the chart.
++The title object for the chart. +
# File 'lib/axlsx/drawing/chart.rb', line 29 -def title - @title -end+def title + @title +end +
The 3D view properties for the chart
++The 3D view properties for the chart +
# File 'lib/axlsx/drawing/chart.rb', line 10 -def view3D - @view3D -end+def view3D + @view3D +end +
Adds a new series to the chart's series collection.
++Adds a new series to the chart’s series collection. +
# File 'lib/axlsx/drawing/chart.rb', line 106 -def add_series(={}) - @series_type.new(self, ) - @series.last -end+def add_series(={}) + @series_type.new(self, ) + @series.last +end +
This is a short cut method to set the end anchor position If you need finer -granularity in positioning use graphic_frame.anchor.to.colOff / rowOff
++This is a short cut method to set the end anchor position If you need finer +granularity in positioning use graphic_frame.anchor.to.colOff / rowOff +
The column
++The column +
The row
++The row +
# File 'lib/axlsx/drawing/chart.rb', line 154 -def end_at(x, y) - @graphic_frame.anchor.to.col = x - @graphic_frame.anchor.to.row = y -end+def end_at(x, y) + @graphic_frame.anchor.to.col = x + @graphic_frame.anchor.to.row = y +end +
This will be disconinued in version 2.0.0. please use the start_at method
++This will be disconinued in version 2.0.0. please use the start_at method +
backwards compatibility to allow chart.to and chart.from access to anchor -markers
++backwards compatibility to allow chart.to and chart.from access to anchor +markers +
# File 'lib/axlsx/drawing/chart.rb', line 99 -def from - @graphic_frame.anchor.from -end+def from + @graphic_frame.anchor.from +end +
The index of this chart in the workbooks charts collection
++The index of this chart in the workbooks charts collection +
# File 'lib/axlsx/drawing/chart.rb', line 61 -def index - @graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self) -end+def index + @graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self) +end +
The part name for this chart
++The part name for this chart +
# File 'lib/axlsx/drawing/chart.rb', line 67 -def pn - "#{CHART_PN % (index+1)}" -end+def pn + "#{CHART_PN % (index+1)}" +end +
This is a short cut method to set the start anchor position If you need +
+This is a short cut method to set the start anchor position If you need finer granularity in positioning use graphic_frame.anchor.from.colOff / -rowOff
+rowOff +The column
++The column +
The row
++The row +
# File 'lib/axlsx/drawing/chart.rb', line 143 -def start_at(x, y) - @graphic_frame.anchor.from.col = x - @graphic_frame.anchor.from.row = y -end+def start_at(x, y) + @graphic_frame.anchor.from.col = x + @graphic_frame.anchor.from.row = y +end +
This will be disconinued in version 2.0.0. Please use the end_at method
++This will be disconinued in version 2.0.0. Please use the end_at method +
backwards compatibility to allow chart.to and chart.from access to anchor -markers
++backwards compatibility to allow chart.to and chart.from access to anchor +markers +
# File 'lib/axlsx/drawing/chart.rb', line 93 -def to - @graphic_frame.anchor.to -end+def to + @graphic_frame.anchor.to +end +
Chart Serialization serializes the chart
++Chart Serialization serializes the chart +
# File 'lib/axlsx/drawing/chart.rb', line 113 -def to_xml - builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml| - xml.send('c:chartSpace',:xmlns:c' => XML_NS_C, :xmlns:a' => XML_NS_A) { - xml.send('c:date1904', :val=>Axlsx::Workbook.date1904) - xml.send('c:style', :val=>style) - xml.send('c:chart') { - @title.to_xml(xml) unless @title.nil? - @view3D.to_xml(xml) unless @view3D.nil? - xml.send('c:plotArea') { - xml.send('c:layout') - yield xml if block_given? - } - if @show_legend - xml.send('c:legend') { - xml.send('c:legendPos', :val => "r") - xml.send('c:layout') - } - end - } - } - end - builder.to_xml -end+def to_xml + builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml| + xml.send('c:chartSpace',:'xmlns:c' => XML_NS_C, :'xmlns:a' => XML_NS_A) { + xml.send('c:date1904', :val=>Axlsx::Workbook.date1904) + xml.send('c:style', :val=>style) + xml.send('c:chart') { + @title.to_xml(xml) unless @title.nil? + @view3D.to_xml(xml) unless @view3D.nil? + xml.send('c:plotArea') { + xml.send('c:layout') + yield xml if block_given? + } + if @show_legend + xml.send('c:legend') { + xml.send('c:legendPos', :val => "r") + xml.send('c:layout') + } + end + } + } + end + builder.to_xml +end +