Home > database >  Google Sheets Chart Axis Title does not update when source cell is formula
Google Sheets Chart Axis Title does not update when source cell is formula

Time:06-11

I want the Google Sheets chart x-axis title to change when the data in a chart changes. I've made a simple example to demonstrate the problem. In the following animated gif (click to see greater detail) the x-axis title does not update when the data in the scatter chart changes.

enter image description here

Apparently this happens because the source cell for that title (A1) is itself a formula (to give the average of the x-values -- in my real-world example, it's more complicated than that).

The only way I know to fix this is to delete the chart and make a new one, as shown in the last part of the animation. But with my real-world example, this is a lot more troublesome.

Thanks for any help.

CodePudding user response:

I have been running a couple of tests and have some experience on how the charts are created under Sheets in comparison to the ones in Excel.

There have been multiple forums discussing this particular issue, the main issue with it is the fact that this portion of the Chart is only a title text and does not linked to any portion to the table or that you cannot select a custom formula to be used for updates. It is also mentioned over the enter image description here

As an alternative, you could implement a script so it changes the chart title for the average.

function onOpen(){
  SpreadsheetApp.getUi().createMenu('Charts').addItem('Update title of the first chart from active cell', 'myFunction').addToUi();
}
function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var chart = sheet.getCharts()[0];
  chart = chart.modify()
  .setOption('title', sheet.getActiveCell().getValue() || 'Empty')
  .build();
  sheet.updateChart(chart);
}

The portion of this code has been found and discussed over this thread.

I also believe that it should be a feature directly on Sheets and it should be implemented in the future, you can send feedback from the help option or go to the Feature ideas portal:

  • Related