<?php /** * INCLUDE CLASS * Show: https://developers.google.com/chart/interactive/docs/customizing_tooltip_content?hl=es#tooltip_actions */ include dirname(dirname(__FILE__)) . '/src/GoogleCharts.class.php'; $GoogleCharts = new GoogleCharts(); //SET DATA $GoogleCharts->arrayToDataTable(array(array('Genre', 'Percentage of my books'), array('Science Fiction', 217), array('General Science', 203), array('Computer Science', 175), array('History', 155), array('Economics & Political Science', 98), array('General Fiction', 72), array('Fantasy', 51), array('Law', 29))); //SET ACTION $GoogleCharts->setAction(array('id' => 'sample', 'text' => 'See sample book', 'action' => 'function(){ selection = chart.getSelection(); switch (selection[0].row) { case 0: alert("Ender\'s Game"); break; case 1: alert("Feynman Lectures on Physics"); break; case 2: alert("Numerical Recipes in JavaScript"); break; case 3: alert("Truman"); break; case 4: alert("Freakonomics"); break; case 5: alert("The Mezzanine"); break; case 6: alert("The Color of Magic"); break; case 7: alert("The Law of Superheroes"); break; }}')); //SET OPTIONS $GoogleCharts->options(array('tooltip' => array('trigger' => 'selection'))); /** * CHART */ $chart = $GoogleCharts->load('pie', 'tooltip_action')->get(); ?>
<?php /** * INCLUDE CLASS */ include dirname(dirname(__FILE__)) . '/src/GoogleCharts.class.php'; $GoogleCharts = new GoogleCharts(); /** * DATA */ $data = array(array('Task', 'Hours per Day'), array('Work', 11), array('Eat', 2), array('Commute', 2), array('Watch Television', 2)); //SET DATA $GoogleCharts->arrayToDataTable($data); // ROW $GoogleCharts->updateRow(1, array('Wandering', 12)); //UPDATE COLUMN $GoogleCharts->updateColumn(4, 0, 'Watch TV'); //APPEND ROW $GoogleCharts->appendRow(array()); //APPED COLUMN $GoogleCharts->appendColumn(5, 5); //PREPEND COLUMN $GoogleCharts->prependColumn(5, 'This'); //DELETE ROW $GoogleCharts->deleteRow(5); //DELETE COLUMN $GoogleCharts->deleteColumn(1, 0); //PREPEND COLUMN $GoogleCharts->prependColumn(1, 'Working'); //SET OPTIONS $GoogleCharts->options(array("title" => "The decline of 'The 39 Steps'"));