0

I am trying to create a histogram chart using pygsheets .add_chart() function. To do so, I only want to pass a domain argument since I only need one column of data for the histogram. However when I leave out the range argument like this:

output_ws.add_chart(domain=('A1', 'A17'), ranges=None, title='Histogram Chart')

I get the following error:

Traceback (most recent call last):
  File "cloud_functions/sheets_functions/main.py", line 327, in <module>
    get_field_growth_stage_sheet()
  File "cloud_functions/sheets_functions/main.py", line 321, in get_field_growth_stage_sheet
    output_ws.add_chart(domain=('A1', 'A17'), ranges=None, title='Histogram Chart')
  File "/usr/local/lib/python3.7/site-packages/pygsheets/worksheet.py", line 1518, in add_chart
    return Chart(self, domain, ranges, chart_type, title, anchor_cell)
  File "/usr/local/lib/python3.7/site-packages/pygsheets/chart.py", line 36, in __init__
    self._create_chart()
  File "/usr/local/lib/python3.7/site-packages/pygsheets/chart.py", line 282, in _create_chart
    response = self._worksheet.client.sheet.batch_update(self._worksheet.spreadsheet.id, request)
  File "/usr/local/lib/python3.7/site-packages/pygsheets/sheet.py", line 101, in batch_update
    return self._execute_requests(request)
  File "/usr/local/lib/python3.7/site-packages/pygsheets/sheet.py", line 359, in _execute_requests
    response = request.execute(num_retries=self.retries)
  File "/usr/local/lib/python3.7/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/googleapiclient/http.py", line 898, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 500 when requesting https://sheets.googleapis.com/v4/spreadsheets/1xvTqpxGN7voIAEv03fXAlY85EUsY0yehMdiP__3QnOg:batchUpdate?fields=%2A&alt=json returned "Internal error encountered.">

  • It cannot retrieve the page, make sure the sharing settings are set up correctly. – ilyankou May 04 '20 at 14:35
  • Maybe my error is misleading because sending `output_ws.add_chart(domain=('A1', 'A17'), ranges=[('A1', 'A17')], title='Histogram Chart')` works but draws the wrong chart – Jack DiSalvatore May 04 '20 at 15:04

1 Answers1

1

If you need a single column of data what you need single range and empty domain. Since range is what specify the data.

install pygsheets from staging

pip install --no-cache-dir https://github.com/nithinmurali/pygsheets/archive/staging.zip

and try this:

output_ws.add_chart(domain=None, ranges=[('A1', 'A17')], title='Histogram Chart')
Nithin
  • 5,470
  • 37
  • 44