def insert_chart(*args)
      # Check for a cell reference in A1 notation and substitute row and column.
      row, col, chart, x_offset, y_offset, x_scale, y_scale = row_col_notation(args)
      raise WriteXLSXInsufficientArgumentError if [row, col, chart].include?(nil)

      x_offset ||= 0
      y_offset ||= 0
      x_scale  ||= 1
      y_scale  ||= 1

      raise "Not a Chart object in insert_chart()" unless chart.is_a?(Chart) || chart.is_a?(Chartsheet)
      raise "Not a embedded style Chart object in insert_chart()" if chart.respond_to?(:embedded) && chart.embedded == 0

      if chart.already_inserted? || (chart.combined && chart.combined.already_inserted?)
        raise "Chart cannot be inserted in a worksheet more than once"
      else
        chart.already_inserted          = true
        chart.combined.already_inserted = true if chart.combined
      end

      # Use the values set with chart.set_size, if any.
      x_scale  = chart.x_scale  if chart.x_scale  != 1
      y_scale  = chart.y_scale  if chart.y_scale  != 1
      x_offset = chart.x_offset if ptrue?(chart.x_offset)
      y_offset = chart.y_offset if ptrue?(chart.y_offset)

      @charts << [row, col, chart, x_offset, y_offset, x_scale, y_scale]
    end
def insert_chart(*args)
      # Check for a cell reference in A1 notation and substitute row and column.
      row, col, chart, x_offset, y_offset, x_scale, y_scale = row_col_notation(args)
      raise WriteXLSXInsufficientArgumentError if [row, col, chart].include?(nil)

      x_offset ||= 0
      y_offset ||= 0
      x_scale  ||= 1
      y_scale  ||= 1

      raise "Not a Chart object in insert_chart()" unless chart.is_a?(Chart) || chart.is_a?(Chartsheet)
      raise "Not a embedded style Chart object in insert_chart()" if chart.respond_to?(:embedded) && chart.embedded == 0

      if chart.already_inserted? || (chart.combined && chart.combined.already_inserted?)
        raise "Chart cannot be inserted in a worksheet more than once"
      else
        chart.already_inserted          = true
        chart.combined.already_inserted = true if chart.combined
      end

      # Use the values set with chart.set_size, if any.
      x_scale  = chart.x_scale  if chart.x_scale  != 1
      y_scale  = chart.y_scale  if chart.y_scale  != 1
      x_offset = chart.x_offset if ptrue?(chart.x_offset)
      y_offset = chart.y_offset if ptrue?(chart.y_offset)

      @charts << [row, col, chart, x_offset, y_offset, x_scale, y_scale]
    end
:call-seq:
   insert_chart(row, column, chart [ , x, y, x_scale, y_scale ] )

 This method can be used to insert a Chart object into a worksheet.
 The Chart must be created by the add_chart() Workbook method and
 it must have the embedded option set.

     chart = workbook.add_chart(:type => 'line', :embedded => 1)

     # Configure the chart.
     ...

     # Insert the chart into the a worksheet.
     worksheet.insert_chart('E2', chart)

 See add_chart() for details on how to create the Chart object and
 Writexlsx::Chart for details on how to configure it. See also the
 chart_*.rb programs in the examples directory of the distro.

 The +x+, +y+, +x_scale+ and +y_scale+ parameters are optional.

 The parameters +x+ and +y+ can be used to specify an offset from the top
 left hand corner of the cell specified by +row+ and +column+. The offset
 values are in pixels.

     worksheet1.insert_chart('E2', chart, 3, 3)

 The parameters x_scale and y_scale can be used to scale the inserted
 image horizontally and vertically:

     # Scale the width by 120% and the height by 150%
     worksheet.insert_chart('E2', chart, 0, 0, 1.2, 1.5)