Difference between revisions of "Google Charts API"
Line 8: | Line 8: | ||
==Data== | ==Data== | ||
− | The [[https://developers.google.com/chart/interactive/docs/reference#DataTable DataTable]] class stores data to be used by charts. | + | The [[https://developers.google.com/chart/interactive/docs/reference#DataTable DataTable]] class stores data to be used by charts. You can use a single datatable with multiple charts. |
* Data can be imported via JSON or via arrays using [[https://developers.google.com/chart/interactive/docs/reference#dataparam this syntax]]. | * Data can be imported via JSON or via arrays using [[https://developers.google.com/chart/interactive/docs/reference#dataparam this syntax]]. | ||
+ | |||
+ | ==Dashboards== | ||
+ | The [[ | ||
==Charts== | ==Charts== | ||
+ | Charts are | ||
===Options=== | ===Options=== | ||
Line 45: | Line 49: | ||
==Views== | ==Views== | ||
− | The [[https://developers.google.com/chart/interactive/docs/reference#DataView DataView]] class changes how a DataTable is represented. | + | The [[https://developers.google.com/chart/interactive/docs/reference#DataView DataView]] class changes how a DataTable is represented. It's a wrapper that |
− | |||
− | |||
==Controls== | ==Controls== | ||
− | + | The [[https://developers.google.com/chart/interactive/docs/gallery/controls#gallery controls]] are filters that affect how data is represented in a chart. They're instantiated with JSON options similar to charts. In order to affect charts they must be bound to the chart using this snippet: "dashboard.bind(control, chart);". | |
Line 61: | Line 63: | ||
# empty | # empty | ||
# incorrectly formatted | # incorrectly formatted | ||
− | # of incorrect type | + | # of incorrect format for that chart type |
# lacking vital information such as headers | # lacking vital information such as headers | ||
Line 78: | Line 80: | ||
** [[https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart pie chart]] | ** [[https://google-developers.appspot.com/chart/interactive/docs/gallery/piechart pie chart]] | ||
** [[https://google-developers.appspot.com/chart/interactive/docs/gallery/combochart combo chart]] | ** [[https://google-developers.appspot.com/chart/interactive/docs/gallery/combochart combo chart]] | ||
+ | |||
==External== | ==External== | ||
+ | [[http://en.wikipedia.org/wiki/Google_Chart_API Wikipedia Overview]] | ||
+ | [[https://developers.google.com/chart/interactive/docs/gallery/controls#gallery Discrete vs Continuous timelines]] | ||
+ | |||
==Snippets== | ==Snippets== |
Revision as of 16:56, 28 February 2014
Under construction during Spring 2014.
Contents
Summary
Introduction
Google Charts are relatively easy to get running but have a lot of nuance to them. Please make use of existing documentation and resources as it will help you immensely.
Data
The [DataTable] class stores data to be used by charts. You can use a single datatable with multiple charts.
- Data can be imported via JSON or via arrays using [this syntax].
Dashboards
The [[
Charts
Charts are
Options
Chart options can be set in multiple ways. Here's [documentation] and some examples.
- options can be set in the following ways:
- at creation by passing JSON as the chart's options parameter
- Example:
- at creation by passing JSON as the chart's options parameter
var options = {
width: 400,
height: 240,
title: 'Toppings I Like On My Pizza',
colors: ['#e0440e', '#e6693e', '#ec8f6e', '#f3b49f', '#f6c7b6']
};
- chart.setOptions(JSON) which is equivalent to setting options at creation
- chart.setOption('key', value) where key is the option being changed
- Example:
chart.setOption('is3D', true);
- chart.getOptions() is the read accessor
Drawing
- draw a chart by using chart.draw(data, options) where data is a datatable and options is JSON
chart.draw(data, options);
Views
The [DataView] class changes how a DataTable is represented. It's a wrapper that
Controls
The [controls] are filters that affect how data is represented in a chart. They're instantiated with JSON options similar to charts. In order to affect charts they must be bound to the chart using this snippet: "dashboard.bind(control, chart);".
Errors
They're a hassle. Most Javascript errors can be debugged from your browser's developer console. Google Charts drawing errors, on the other hand, seem to provide little feedback.
Generally a chart fails to draw in the following ways.
- when the DataTable is
- empty
- incorrectly formatted
- of incorrect format for that chart type
- lacking vital information such as headers
- when the Chart's options are incorrect such as
- wrong chart type [documentation]
- wrong axis type (discrete/continuous) [documentation]
Resources
- Here are some good charts to start with.
- [column chart]
- [table chart]
- [pie chart]
- [combo chart]
External
[Wikipedia Overview] [Discrete vs Continuous timelines]