5

Google Spreadsheets offers the option to put a chart on its own sheet (instead of inserting it in the current sheet). This looks like a good idea for large charts.

However, I ran into an issue when publishing such charts on the web. If a chart is inserted into a sheet, the published version matches the size it has in the sheet (example). But if a chart lives on its own sheet, the published version has fixed size, and pretty small at that.

Is there any way to control the size of a published chart that lives on its own sheet?

1
  • Thank you for identifying the workaround, that embedding a chart on a sheet allows you to publish and get it at full size! Charts published from their own sheet are way too small.
    – Dan Kohn
    May 19, 2017 at 23:36

2 Answers 2

1

As far as I know, there isn't a way to do that. Instead, create a Web App so will have access to more options for your charts.

One alternative is to use Google Apps Script HtmlService.

Example

Code.gs

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

index.html

<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

  // Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});
  
  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawGID);
  
  // Callback that creates and populates a data table, 
  // instantiates the chart, passes in the data and
  // draws it.
  
  function drawGID() {
  var queryString = encodeURIComponent('SELECT A, H, O, Q, R, U LIMIT 5 OFFSET 8');

  var query = new google.visualization.Query(
      'https://docs.google.com/spreadsheets/d/1XWJLkAwch5GXAt_7zOFDcg8Wm8Xv29_8PWuuW15qmAE/gviz/tq?gid=0&headers=1&tq=' + queryString);
  query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
  if (response.isError()) {
    alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
    return;
  }

  var data = response.getDataTable();
  var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
  chart.draw(data, { height: 400 });
}

</script>
<!--Div that will hold the chart-->
<div id="chart_div" style="width:400; height:300"></div>

References
Create a chart or graph - Docs Editors Help
Google Charts > Google Spreadsheets - Google Developers

2

It is possible to get a chart that is the dimensions of your current screen. For that, move the chart to a new sheet, and "publish" it.

publish dialog

Important: Do not select anything ("None") in the "Published content & settings" section, otherwise your chart will be tiny (default size for image export).

Open the publish-URL and right-click on the chart to download a high-res picture.

1
  • FWIW The None option doesn't seem to work any longer so this 'hack' also no longer seems to work Sep 17, 2021 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.