Class: Axlsx::TwoCellAnchor
- Inherits:
-
Object
- Object
- Axlsx::TwoCellAnchor
- Defined in:
- lib/axlsx/drawing/two_cell_anchor.rb
Overview
The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
This class details the anchor points for drawings.
Instance Attribute Summary (collapse)
-
- (Drawing) drawing
readonly
The drawing that holds this anchor.
-
- (Marker) from
readonly
A marker that defines the from cell anchor.
-
- (GraphicFrame) graphic_frame
readonly
The frame for your chart.
-
- (Integer) index
readonly
The index of this anchor in the drawing.
-
- (Marker) to
readonly
A marker that returns the to cell anchor.
Instance Method Summary (collapse)
-
- (TwoCellAnchor) initialize(drawing, chart_type, options)
constructor
Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the graphic_frame’s chart.
-
- (String) to_xml(xml)
Serializes the two cell anchor.
Constructor Details
- (TwoCellAnchor) initialize(drawing, chart_type, options)
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
34 35 36 37 38 39 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 34 def initialize(drawing, chart_type, ) @drawing = drawing drawing.anchors << self @from, @to = Marker.new, Marker.new(:col => 5, :row=>10) @graphic_frame = GraphicFrame.new(self, chart_type, ) end |
Instance Attribute Details
- (Drawing) drawing (readonly)
The drawing that holds this anchor
20 21 22 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 20 def drawing @drawing end |
- (Marker) from (readonly)
A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
9 10 11 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 9 def from @from end |
- (GraphicFrame) graphic_frame (readonly)
The frame for your chart
16 17 18 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 16 def graphic_frame @graphic_frame end |
- (Integer) index (readonly)
The index of this anchor in the drawing
24 25 26 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 24 def index @drawing.anchors.index(self) end |
- (Marker) to (readonly)
A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively
12 13 14 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 12 def to @to end |
Instance Method Details
- (String) to_xml(xml)
Serializes the two cell anchor
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 47 def to_xml(xml) #build it for now, break it down later! xml.send('xdr:twoCellAnchor') { xml.send('xdr:from') { from.to_xml(xml) } xml.send('xdr:to') { to.to_xml(xml) } @graphic_frame.to_xml(xml) xml.send('xdr:clientData') } end |