This article will show you how to connect Google Sheets with Charts 4 PHP framework

Step 1: Give permission to access Google Spreadsheet

Before proceeding to next step make sure that your google sheet have permission to view :

Goto your My Driver folder and right click on the spreadsheet you want to share. Then select :  “Anyone with the link can view “from dropdown . (See screenshots)



Step 2: Add your spreadsheet key and sheet name 

Change the key and sheet_name  as given in your spreadsheet with following format :{key}/gviz/tq?tqx=out:csv&sheet={sheet_name}

in our case, after adding key and sheet name, the url becomes:


Step 3: Include Charts 4 PHP Library

$p = new chartphp();


Step 4: Set your google sheet url in a string 

So finally we have this link (saved in url variable) :

$url = "";
$p->data_csv_url = $url;

In our case-example the sheet is:


By default , first column (Downloads) and second column (Week 0) are selected (highlighted above). To make charts from other 2 columns, see Documentation.

Also Note that the chart will be made for 2 columns only. More than 2 columns are currently not supported.

Step 4: Set title for the chart

$p->title = "Downloads / Day";

Step 5: Render Chart

$out = $p->render("c1");


This feature is currently supported in paid version only.

Whats Next:

  • To download latest free version (with limited features), please visit our Download page.
  • To buy full functional paid version with technical support, please visit our Pricing page.
  • For existing paid customers who want to renew/upgrade, please visit Upgrade page.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!