Create Google Charts on the server with the Kohana Libary
Kogoochart is a library built specifically for the Kohana PHP framework to utilize the Google Chart API.
= Introduction =
See the in code documentation for how to use the library. In time I will create more detailed documentation on how to use the library and each of it's functions.
= Simple Example =
{{{ // Data $data_1 = array('Hello' => 60, 'World' => 40);
// Create object $google_chart_1 = Google_Chart::factory();
// Set attributes $google_chart_1->set_attributes(array( 'encoding' => 'text', 'size' => array('250', '100'), 'chart' => 'pie_3d', 'data' => $data_1, ));
// Display the chart echo $google_chart_1->display(); }}}
Outputs
= Less Simple Example =
{{{ // Data $data_2 = array(48, 36, 20, -15, 26, 53, 60, 11, 3, 19);
// Create object $google_chart_2 = Google_Chart::factory();
// Set attributes $google_chart_2->set_attributes(array( 'encoding' => 'text', 'title' => 'My First Chart', 'size' => array('500', '300'), 'chart' => 'vertical_bar', 'color' => array('FFDFC1'), 'data' => $data_2, 'axis_type' => array('x', 'y'), 'bar_width_and_spacing' => 'auto', 'data_scale' => 'auto', ));
// Display the chart echo $google_chart_2->display(); }}}
Outputs
= Line chart example with line styles =
{{{ // Data $data_3_1 = array(10, 20, 40, 20, 30, 50, 80, 90, 70); $data_3_2 = array(5, 10, 15, 20, 25, 30, 35, 40, 45);
// Create object $google_chart_3 = Google_Chart::factory();
// Set attributes $google_chart_3->set_attributes(array( 'encoding' => 'text', 'title' => 'Line Chart Test', 'size' => array('500', '300'), 'chart' => 'line', 'data' => array($data_3_1, $data_3_2), 'axis_type' => array('x', 'y'), 'bar_width_and_spacing' => 'auto', 'line_style' => array(array('5', '2', '3'), array(1, 3, 4)), ));
// Display the chart (magical toString method) echo $google_chart_3; }}}
Outputs