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 NOTE: Discontinued.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(anchor, chart_type, options) ⇒ GraphicFrame
Creates a new GraphicFrame object
19 20 21 22 23 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 19 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
14 15 16 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 14 def anchor @anchor end |
#chart ⇒ Chart (readonly)
A reference to the chart object associated with this frame
10 11 12 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 10 def chart @chart end |
Instance Method Details
#rId ⇒ String
The relationship id for this graphic NOTE: Discontinued. This should not be part of GraphicFrame. The drawing object maintains relationships and needs to be queried to determine the relationship id of any given graphic data child object.
31 32 33 34 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 31 def rId warn('axlsx::DEPRECIATED: GraphicFrame#rId has been depreciated. relationship id is determed by the drawing object') "rId#{@anchor.index+1}" end |
#to_xml_string(str = '') ⇒ String
Serializes the object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/axlsx/drawing/graphic_frame.rb', line 39 def to_xml_string(str = '') # macro attribute should be optional! str << '<xdr:graphicFrame>' str << '<xdr:nvGraphicFramePr>' str << '<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>' str << '<xdr:cNvGraphicFramePr/>' str << '</xdr:nvGraphicFramePr>' str << '<xdr:xfrm>' str << '<a:off x="0" y="0"/>' str << '<a:ext cx="0" cy="0"/>' str << '</xdr:xfrm>' str << '<a:graphic>' str << '<a:graphicData uri="' << XML_NS_C << '">' str << '<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="rId' << (@anchor.drawing.index_of(@chart)+1).to_s << '"/>' str << '</a:graphicData>' str << '</a:graphic>' str << '</xdr:graphicFrame>' end |