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