I am reading in a template file that has a series of charts. The charts on sheet "Charts" are based on data sets from a second sheet "RawData". I am trying to change the data set/range that feeds the chart - my assumption is that simply changing the data set will auto expand/shrink the chart.
In excel
From:
headings: =RawData!$A$1:$H$1
data =RawData!$A$2:$H$2
To:
headings: =RawData!$A$1:$M$1
data =RawData!$A$2:$M$2
I can find the chart I need to change, but I can't figure out how to get/set the dataSource of the chart. I think I should be able to extract it with getDataSource()
but I can't figure out how to properly use the method:
foreach ($spreadsheet->getSheetByName("Chart Data")->getChartCollection() as $chart) {
if ($chart->getTitle()->getCaptionText() == "Chart_12") {
// "Chart_12" is a manually assigned chart title in the template file
$chart->getDataSource() ; <--- error: undefined method
break ;
}
}
getDataSource()
is a listed method in the documentation: getDataSource - hopefully someone can assist as this is driving me nuts.