Class: Axlsx::GraphicFrame
- Inherits:
-
Object
- Object
- Axlsx::GraphicFrame
- Defined in:
- lib/axlsx/drawing/graphic_frame.rb
Overview
The recommended way to manage charts is Worksheet#add_chart
A graphic frame defines a container for a chart object
Instance Attribute Summary (collapse)
-
- (TwoCellAnchor) anchor
readonly
A anchor that holds this frame.
-
- (Chart) chart
readonly
A reference to the chart object associated with this frame.
-
- (String) rId
readonly
The relationship id for this graphic.
Instance Method Summary (collapse)
-
- (GraphicFrame) initialize(anchor, chart_type, options)
constructor
Creates a new GraphicFrame object.
-
- (String) to_xml(xml)
Serializes the graphic frame.
Constructor Details
- (GraphicFrame) initialize(anchor, chart_type, options)
Creates a new GraphicFrame object
24 25 26 27 28 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 24 def initialize(anchor, chart_type, ) DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type @anchor = anchor @chart = chart_type.new(self, ) end |
Instance Attribute Details
- (TwoCellAnchor) anchor (readonly)
A anchor that holds this frame
15 16 17 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 15 def anchor @anchor end |
- (Chart) chart (readonly)
A reference to the chart object associated with this frame
11 12 13 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 11 def chart @chart end |
- (String) rId (readonly)
The relationship id for this graphic
19 20 21 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 19 def rId "rId#{@anchor.index+1}" end |
Instance Method Details
- (String) to_xml(xml)
Serializes the graphic frame
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 37 def to_xml(xml) xml.send('xdr:graphicFrame') { xml.send('xdr:nvGraphicFramePr') { xml.send('xdr:cNvPr', :id=>2, :name=>chart.title) xml.send('xdr:cNvGraphicFramePr') } xml.send('xdr:xfrm') { xml.send('a:off', :x=>0, :y=>0) xml.send('a:ext', :cx=>0, :cy=>0) } xml.send('a:graphic') { xml.send('a:graphicData', :uri=>XML_NS_C) { xml.send('c:chart', :'xmlns:c'=>XML_NS_C, :'xmlns:r'=>XML_NS_R, :'r:id'=>rId) } } } end |