Home > Uncategorized > Generate static graph images for embedding into emails

Generate static graph images for embedding into emails

fsThe Google Graph API is great, but it’s Javascript based, so therefore unsuitable for embedding into emails, since most, if not all email clients will block the execution of Javascript.

The Google static chart API is an option, but it is officially deprecated, and may not be supported beyond 2015.

Here is an unusual solution, which can be used to generate an image from a web page, and then the resultant image can be embedded into a HTML based email.

First, I took Google’s simple “Pie chart” example, and replaced all the values with variables read from the query string: i.e.

function drawChart() {

var data = new google.visualization.DataTable();
data.addColumn(‘string’, getParameterByName(“datatitle”));
data.addColumn(‘number’, getParameterByName(“valuetitle”));

var options = {‘title’:getParameterByName(“title”),’width’:”100%”,’height’:”100%”};

var chart = new google.visualization.PieChart(document.getElementById(‘chart_div’));
chart.draw(data, options);

Put this online as a web-page, which can be called like this:


Then using a thumbnail generator service, I can create an image from this:


– Which could then be embedded into an email using a simple <img> tag.


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: