GoogleCharts Library

The GoogleCharts API is based on the Google Image Charts API, and parameters mirror the parameters in the API.

List of parameters is available here:

https://developers.google.com/chart/image/docs/chart_params

 

Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import GoogleCharts



Functions

 

GoogleCharts.get_chart_url(**kwargs):

Usage: Charts.get_chart_url(kwargs)**

import GoogleCharts

todays_data = [3,5,7,2,4,6,7,8]

# Line Chart example
url = GoogleCharts.get_chart_url(
    chtt="Today's data", #title
    cht="lc", # line chart type
    chs="320x200", # size
    chd=[["%0.3f" % x for x in todays_data]], # formatted data
    chxt=[["x", "y"]], # axis to show
    chco=[["8ec952"]], # color
    chxr=[[0, 0,0], [1, 0.9 * min(todays_data), 1.1 * max(todays_data)]], # data range
    chds=[[0.9 * min(todays_data), 1.1 * max(todays_data)]] # data scale
)

# Stacked Bar chart example
duty_cycles = [50, 60, 70, 80, 30, 40, 50]

url2 = GoogleCharts.get_chart_url(
    chtt="Duty Cycle",  # chart title
    cht="bvs",  # chart type: vertical bars, stacked
    chs="320x200",  # chart image size
    chd=[duty_cycles, [100 - dc for dc in duty_cycles]],  # dataset: duty cycle values, and their complement
    chxt=[["x", "y"]],  # axis to show
    chco=[["8ec952", "5cb6c5"]],  # colors of each segment
    chxr=[[0, 1, 7, 1], [1, 0, 100, 10]],  # axis scales: axis 0, from 1 to 7 (days) with step 1, axis 1 from 0 to 100 (%) with step 10
    chbh=[[30, 12]] # bar width and spacing
)
  • Returns: 'str`

Returns the url to use in an email or sms message

Have more questions? Submit a request

0 Comments

Article is closed for comments.