Fork me on GitHub

Project Notes

Google Chart Basics

Getting up and running and understanding the latest from Google Charts

Notes

Google Charts has come a long way from doing simple inline line charts. My bottom line:

Positives:

  • well designed API
  • very good documentation
  • quite extensive capabilities

Negatives:

  • not available for offline or stand-alone packaging and distribution

Loading Charts Library

Loading

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
  google.charts.load('current', {packages: ['corechart']});
  google.charts.setOnLoadCallback(drawChart);
  ...
</script>

Unlike other libraries, Google Charts is not released for stand-alone packaging and distribution. This may eliminate it as an option for some scenarios like content serving behind restrictive firewalls or over poor wide-area networks. From the FAQ:

Our terms of service do not allow you to download the google.charts.load or google.visualization code to use offline.

Making a Chart Dynamic

The DataTable class provides all the methods you need to update the data to be visualised. Calling draw(data, options) on the chart will update the data and also let’s one change options too.

It seems inefficient (but presumably internally optimised?) but works just fine.

Quite Test: Pie Chart

See example_pie.html

example_pie

Credits and References

About LCK#84 javascriptgraphics
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.