What is "google-charts"

The Google Chart API is an online tool developed by Google that makes it possible to create dynamic charts through web pages in minutes, its operation is quite simple, it just makes an HTTP request by sending parameters and returns an image in PNG format with the requested chart.

This way, you can quickly have a chart to insert into your site, blog or even to insert into a document. doc or .xls. This API makes it possible to create numerous types of graphics, from pie charts, lines, bars etc.

The only requirement is that the user is connected to the internet. This tool is pleasing to the entire programmer community as it is a quick and practical way to quickly have professional-looking graphics. Much of the documentation is in English, but with a fully understandable vocabulary.

How to use Google Chart?

The use of Google Chart is quite simple, you put in your HTML IMG tag the image path that the Google API generates. We don’t need to import any libraries or anything like that. The Google API provides a wide range of graphics, from the simplest to the most complex.

There are numerous customizations that can be made, from the dimensions, colors, types of filler etc.

The format that the URL should contain to generate the chart is as follows:

http://chart.apis.google.com/chart?cht=[chart type]&chd=t:[values]&chs=[dimensions]&chco=[colors]&chtt=[title]&chl=[parameters]

Begin the creation

The graphics start from the HTTP request of the URL that is made in your browser:

http://chart.apis.google.com/chart? 

followed by the parameters we want to create the chart. Below follows some parameters for creating the charts with their respective functions:

  • CHXL - for label creation;
  • CHDL - caption;
  • CHCO - chart colors;
  • CHT - chart type;
  • CHTT - chart title;
  • CHXT - command for creating axes, such as "chxt=x,y";
  • CHD - command with text values (string) "text";
  • CHTT - acronym for creating the title of your chart, as "chtt=Title+do+my+graphic".