class Axlsx::GraphicFrame

A graphic frame defines a container for a chart object @note The recommended way to manage charts is Worksheet#add_chart @see Worksheet#add_chart

Attributes

anchor[R]

A anchor that holds this frame @return [TwoCellAnchor]

chart[R]

A reference to the chart object associated with this frame @return [Chart]

Public Class Methods

new(anchor, chart_type, options) click to toggle source

Creates a new GraphicFrame object @param [TwoCellAnchor] anchor @param [Class] chart_type

# File lib/axlsx/drawing/graphic_frame.rb, line 19
def initialize(anchor, chart_type, options)
  DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type
  @anchor = anchor
  @chart = chart_type.new(self, options)
end

Public Instance Methods

rId() click to toggle source

The relationship id for this graphic frame. @return [String]

# File lib/axlsx/drawing/graphic_frame.rb, line 27
def rId
  @anchor.drawing.relationships.for(chart).Id
end
to_xml_string(str = '') click to toggle source

Serializes the object @param [String] str @return [String]

# File lib/axlsx/drawing/graphic_frame.rb, line 34
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 << '"/>')
  str << '</a:graphicData>'
  str << '</a:graphic>'
  str << '</xdr:graphicFrame>'
end