By @mhawksey

Generating charts from accessible data tables using the Google Charts API

I was recently looking for an accessible way to generate chart data when I came across Chris Heilmann example for Generating charts from accessible data tables and vice versa using the Google Charts API. One of the limitations of Chris’s solution was it only generated pie charts. Having some time to kill over the weekend I’ve made some additions to Chris’s original script. The biggest change has been the inclusion of line charts.

The changes are probably best illustrated by this demo page. On this page I’ve copied Chris’s original pie charts and included the new charts generated by the script. Most of the changes reflect suggestions from the comments on Chris’s blog (i.e. alt tag [Ben  Millard], fixed 3 digit limit [Robin Winslow]).

The big addition has been the inclusion of support for line charts. This uses the same principle of reading data from a table but unlike the original script which only read the first two columns the new script now reads in the entire table. Table headings are read as the data legends and the y-axis automatically scales to fit the entire data range (so far I’ve only got it working for absolute numbers).

One feature I’ve removed from Chris’s original script is the function to create a table from a chart.

You can download the script with the demo page and have a play around yourself. If anyone else is interested in developing this further leave a comment.

[I should also point out that I’m a ‘hack’ programmer so if anyone would like to tidy up my revised code please feel free].

Exit mobile version