<?php
include_once 'config.inc.php';
?><html>
<head>
<?php
# new visualization using template default
$v = new Google_Visualization("Default");
# register package
$p = new Google_Package();
$p->packages = array("table");
$p->language = "de_DE";
$v->setPackage($p); // set package object to visualization
# new data object
$o = new Google_Data_Base();
$o->addColumn("0","Name","string");
$o->addColumn("1","Age","string");
$o->addColumn("2","Instrument","string");
$o->addColumn("3","Color","string");
$o->addNewRow();
$o->addStringCellToRow("John");
$o->addStringCellToRow(24);
$o->addStringCellToRow("Guitar");
$o->addStringCellToRow("Blue");
$o->addNewRow();
$o->addStringCellToRow("Paul");
$o->addStringCellToRow(25);
$o->addStringCellToRow("Guitar");
$o->addStringCellToRow("Red");
$o->addNewRow();
$o->addStringCellToRow("George");
$o->addStringCellToRow(22);
$o->addStringCellToRow("Bass");
$o->addStringCellToRow("Yellow");
$o->addNewRow();
$o->addStringCellToRow("Ringo");
$o->addStringCellToRow(25);
$o->addStringCellToRow("Drums");
$o->addStringCellToRow("Black");
# inject data object into data table
$dt = new Google_Data_Table;
$dt->setDataTable("dataTable");
$dt->assignData($o);
$v->setDataTable($dt); //set data table object to visualization
# setup a new draw function
$f = new Google_Function('drawVisualization');
# some var names
$dataVar = "table1";
$dataVar2 = "table2";
$dataVar3 = "table3";
$dataTable = "dataTable";
$options = null;
# add container dom object to function
$f->add(Google_Base::getVarById($dataVar));
$f->add(Google_Base::getVarById($dataVar2));
$f->add(Google_Base::getVarById($dataVar3));
# first table
$chart = new Google_Chart("Table", $dataVar);
$chart->draw($dataTable, $options);
$f->add($chart);
# first data view
$dataView = new Google_Data_View();
$dataView->setViewTable("dataView1");
$dataView->setDataTable($dataTable);
$dataView->setColumns(array(0,2));
$f->add($dataView);
# second table
$chart2 = new Google_Chart("Table", $dataVar2);
$chart2->draw($dataView, $options);
$f->add($chart2);
# second data view
$dataView2 = new Google_Data_View();
$dataView2->setViewTable("dataView2");
$dataView2->setDataTable($dataTable);
$dataView2->setColumns(array(0,1,3));
$f->add($dataView2);
# third table
$chart3 = new Google_Chart("Table", $dataVar3);
$chart3->draw($dataView2, $options);
$f->add($chart3);
$f->setCallBack();
$v->setFunction($f); // set function object to visualization
# output
echo $v->render();
?>
</head>
<body style="font-family: Arial;border: 0 none;">
<div style="width:300px;height:140px;float:left;">
<div style="font-size:11px;">Original Data Table</div>
<div id="table1"></div>
</div>
<div style="width:180px;height:140px;float:left;">
<div style="font-size:11px;">A Data View</div>
<div id="table2"></div>
</div>
<div style="width:200px;height:140px;float:left;">
<div style="font-size:11px;">Another Data View</div>
<div id="table3"></div>
</div>
<div style="clear:both;"></div>
<div><?php highlight_string(file_get_contents(basename(__FILE__)));?></div>
</body>
</html>