views:

74

answers:

1

I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to do graphics myself.

I'd also like to follow the advice to use Google Charts API. This will be the first time for me.

But I don't want to do an Excel chart — however much that might appeal to my co-workers who use Excel for everything. I like the idea of receiving an image of my data.

Obviously, if you're familiar with Statistical Process Control, we're talking about a line chart.

Has anyone been able to 'configure' a Google line chart for SPC?

Because I haven't seen any examples, I'm mostly interested in whether or not it's even possible.

EDIT: well, of course it is possible. Maybe the dearth of previous 'solutions' is created by reluctance to hand sensitive data to Google and wait for a chart to come back.

Accepting your own answer is OK, but for those of you who might wonder, I got no rep points for it.

I could accept something better, if anyone suggests it.

A: 

I decided to take the paranoid approach [that it would create alarm if I sent a whole lot of confidential company information to Google] so here is a fragment of my code. It embeds a Google line chart in a simple table.

The table provides labelling for the chart, and Google gets just 'meaningless' numbers.

The array $values contains real measurements, but they are scaled wrt the upper and lower control limits, so LCL is 10%, and UCL is 90% of the vertical axis.

echo "<table class='noborder'>\n";
echo "<caption class='spc'>Product : Measurement</caption>\n";
echo "<tr><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th></tr>\n";
echo "<tr><td>AVG</td><td>\n";
echo "<img src='http://chart.apis.google.com/chart?cht=lc\n&amp;chd=t:";
printf("%s", implode(',', $values));
echo "\n&chm=o,FF9900,0,-1,10|R,FFDDDD,0,0.0,1.0|r,F9ECEC,0,0.1,0.9";
echo "\n&chs=600x500&chco=0000CC'><td>&nbsp;</td>\n";
echo "<tr><td>&nbsp;</td><th>";
printf("LCL=%6.3f, AVG=%6.3f, UCL=%6.3f", $lcl, $avg, $ucl);
echo "</th><td>&nbsp;</td></tr>\n";
pavium