if (array_key_exists("qry", $_POST) and $_POST["useQuery"] == "on") {
        $query = $_POST["qry"];
    } else {
        $query = 'SELECT A,D WHERE D > 100 ORDER BY D';
    }
} else {
    $chartType = 'AreaChart';
    $query = 'SELECT A,D WHERE D > 100 ORDER BY D';
}
$id = 'viz';
$url = 'http://spreadsheets.google.com/tq?key=pCQbetd-CptGXxxQIG7VFIQ&pub=1';
# new visualization using template default
$v = new Google_Visualization("Default");
# register package
$p = new Google_Package(array("packages" => array($chartType), "language" => "de_DE"));
$v->setPackage($p);
// set package object to visualization
# setup chart
$chart = new Google_Chart($chartType, Google_Base::getElementById($id));
$options = new Google_Config($chartType);
$options->setProperty("width", 550);
$chart->draw("data", $options);
# init functions
$f1 = new Google_Function('drawVisualization');
$f2 = new Google_Function('handleQueryResponse', array('response'));
# setup query
$q = new Google_Data_Query($url);
$q->setQuery($query);
$q->send($f2->getName());
$f1->add($q);
$f1->setCallBack();