lib/axlsx/drawing/two_cell_anchor.rb in axlsx-1.0.7 vs lib/axlsx/drawing/two_cell_anchor.rb in axlsx-1.0.8
- old
+ new
@@ -10,13 +10,18 @@
# A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively
# @return [Marker]
attr_reader :to
# The frame for your chart
+ # @note this will be discontinued in version 2.0 please use object
# @return [GraphicFrame]
- attr_reader :graphic_frame
+ # attr_reader :graphic_frame
+ # The object this anchor hosts
+ # @return [Pic, GraphicFrame]
+ attr_reader :object
+
# The drawing that holds this anchor
# @return [Drawing]
attr_reader :drawing
# The index of this anchor in the drawing
@@ -25,21 +30,29 @@
# Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the
# graphic_frame's chart. That means that you can do stuff like
# c = worksheet.add_chart Axlsx::Chart
# c.start_at 5, 9
+ # @note the chart_type parameter will be replaced with object in v. 2.0.0
# @param [Drawing] drawing
# @param [Class] chart_type This is passed to the graphic frame for instantiation. must be Chart or a subclass of Chart
+ # @param object The object this anchor holds.
# @option options [Array] start_at the col, row to start at
# @option options [Array] end_at the col, row to end at
- def initialize(drawing, chart_type, options)
+ def initialize(drawing, options={})
@drawing = drawing
drawing.anchors << self
@from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
- @graphic_frame = GraphicFrame.new(self, chart_type, options)
end
+ # Creates a graphic frame and chart object associated with this anchor
+ # @return [Chart]
+ def add_chart(chart_type, options)
+ @object = GraphicFrame.new(self, chart_type, options)
+ @object.chart
+ end
+
def index
@drawing.anchors.index(self)
end
# Serializes the two cell anchor
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
@@ -51,10 +64,10 @@
from.to_xml(xml)
}
xml.send('xdr:to') {
to.to_xml(xml)
}
- @graphic_frame.to_xml(xml)
+ @object.to_xml(xml)
xml.send('xdr:clientData')
}
end
private