#!/usr/bin/perl -w use DBI; use DBD::Chart; $dbh = DBI->connect('dbi:Chart:'); $dbh->do('create table stackbar (name varchar(10), yl integer, yh integer)'); $sth = $dbh->prepare('insert into stackbar values(?, ?, ?)'); $sth->execute('foo', 1, 20); $sth->execute('foo', 20, 30); $sth->execute('foo', 50, 30); $sth->execute('bar', 1, 30); $sth->execute('bar', 30, 40); $sth->execute('bar', 70, 40); $sth = $dbh->prepare("select barchart from stackbar where WIDTH=500 AND HEIGHT=500 AND X_AXIS='Some Domain' AND Y_AXIS='Some Range' AND TITLE='Stacked Barchart Test' AND FORMAT='PNG' AND STACK=1 AND SHOWVALUES=1 AND COLORS IN ('green', 'yellow', 'red')"); $sth->execute; $row = $sth->fetchrow_arrayref; open(OUTF, ">barchart_graph.png"); binmode OUTF; print OUTF $$row[0]; close OUTF; $sth->finish; $dbh->disconnect;