Q:

Adjust the chart position of google slide which is created by google spreadsheet

I am trying to adjust the position of Google Apps Script chart on Google Slide. First, the chart is created on a spreadsheet and inserted into the slide. I tried to change the position to right side or center using setLeft() and alignOnPage() methods. But still, the image is positioned top left on the slide. Could someone please show me the proper way to place the chart on the slide? Thank you!    
var chart2 = sheet.newChart().setChartType(Charts.ChartType.PIE).addRange(sheet.getRange(range2)).setOption('applyAggregateData',0).setPosition(5, 5, 0, 0).build();
sheet.insertChart(chart2);
shapes = slide.getShapes();
slide.insertSheetsChart(chart2).setLeft(0).alignOnPage(SlidesApp.AlignmentPosition.CENTER).setWidth(300).setHeight(185);

A:

In your situation, when alignOnPage() is used, at first, please resize the chart using setWidth() and setHeight(). Then use alignOnPage(SlidesApp.AlignmentPosition.CENTER). By this, you can put the resized chart to center of the slide.
When alignOnPage() is run before the chart is resized, the size before the resize is used. So when the chart is resized after the adjustment, the position you don't want is reflected.
Modified script:

From:

slide.insertSheetsChart(chart2)
  .setLeft(0)
  .alignOnPage(SlidesApp.AlignmentPosition.CENTER)
  .setWidth(300)
  .setHeight(185);

To:

slide.insertSheetsChart(chart2)
  .setWidth(300)
  .setHeight(185)
  .alignOnPage(SlidesApp.AlignmentPosition.CENTER);

Note:

If you want to use setLeft() for this modified script, please add it to after alignOnPage().

If this was not the result what you want, I'm sorry.
Added:
About your additional question, how about the following sample script? In this sample, the following flow is run.

Set width and height of the chart.
Set position of top and left.

Sample script:
var s = SlidesApp.getActivePresentation();
var w = 300;
var h = 185;
var ph = s.getPageHeight();
var pw = s.getPageWidth();

slide.insertSheetsChart(chart2)
  .setWidth(w)
  .setHeight(h)
  .setTop(ph - h)
  .setLeft(pw - w);

