I am trying to analyse data from a google sheet using pygsheets wrapper and able to draw a line chart using same. The idea is to run data analysis on daily basis and add/update the chart accordingly.
Here is the data with ranges in Google sheet, python code I am trying with pygsheets and the chart I am getting using pygsheets.add_chart()
# Inserting/Updating chart
chart_title = "Title"
# Range is dynamic, here is a sample range, check resp. sheet SS
chart_range = [('F6', 'L6'), ('F7', 'L7'), ('F8', 'L8'), ('F9', 'L9')]
chart_anchor_cell = 'F2'
chart_domain = None
# Check chart's existence
found_charts = wks.get_charts(chart_title)
if len(found_charts)!=0:
print("Chart Found. Updating chart...")
chart_obj = found_charts[0]
# NOT SURE HOW TO UPDATE IT'S VALUES LIKE UPDATED RANGE, LEGEND, X&Y axis
# .....................................................................
else:
print("Chart not Found. Creating chart...")
chart_obj = wks.add_chart(domain=chart_domain, ranges=chart_range, title=chart_title, chart_type=pygsheets.ChartType.LINE, anchor_cell=chart_anchor_cell)
chart_json = chart_obj.get_json()
# NOT SURE HOW TO UPDATE IT'S VALUES LIKE LEGEND, X&Y axis title, SIZE
# .....................................................................
As the domain element is None, I am not able to use methods update_chart() and get_json(), so it seems impossible for me to update chart's attributes.
Can anybody, please tell me that how I can update chart's values with a Chart object?
Thanks in advance!