Google Chart Add google chart from database tables directly using PDO (Added in v 3.6)

Apart from plugin addition, you can using addChart function to generate google chart/bar/line easily. You just needs to pass type of chart you want to generate and values to be passed. You can pass value as array or get data from database using PDOModel obect easily and pass it as array. Currently following Google charts are supported.

  1. Line Chart
  2. Bar Chart
  3. Pie Chart
  4. Donut Chart
  5. Area Chart

  
                                $pdocrud = new PDOCrud();
                                /**
                                * Add pie chart, bar chart, google charts etc using add chart function
                                * @param   string  $chartName                            Name of the chart
                                * @param   string  $chartType                            Chart type 
                                * @param   mixed   $dataSource                           data source either tablename or array of data
                                * @param   string  $key                                  name of col, that will serve as data key
                                * @param   string  $val                                  name of col, that will serve as field valye
                                * @param   string  $bind                                 whether datasource is db table or array or sql, default is db table
                                * @param   string  $param                                data parameter for the chart element
                                * return   object                                        Object of class
                                */
                                $pdocrud->addChart("chart1", "google-chart", array("'Task'" => "'Hour per day'","'Work'"=>8, "'Eat'"=>2, "'TV'"=>3, "'Gym'"=>4,"'Sleep'"=>9), "", "", "array",array("title" => "Employee Data","width"=>"500", "height"=>"500","google-chart-type"=>"LineChart"));
                                $pdocrud->addChart("chart2", "google-chart", array("'Task'" => "'Hour per day'","'Work'"=>8, "'Eat'"=>2, "'TV'"=>3, "'Gym'"=>4,"'Sleep'"=>9), "", "", "array",array("title" => "Employee Data","width"=>"500", "height"=>"500","google-chart-type"=>"BarChart"));
                                $pdocrud->addChart("chart3", "google-chart", array("'Task'" => "'Hour per day'","'Work'"=>8, "'Eat'"=>2, "'TV'"=>3, "'Gym'"=>4,"'Sleep'"=>9), "", "", "array",array("title" => "Employee Data","width"=>"500", "height"=>"500","google-chart-type"=>"PieChart"));
                                $pdocrud->addChart("chart4", "google-chart", array("'Task'" => "'Hour per day'","'Work'"=>8, "'Eat'"=>2, "'TV'"=>3, "'Gym'"=>4,"'Sleep'"=>9), "", "", "array",array("title" => "Employee Data","width"=>"500", "height"=>"500","pieHole"=> 0.4,"google-chart-type"=>"PieChart"));
                                $pdocrud->addChart("chart5", "google-chart", array("'Task'" => "'Hour per day'","'Work'"=>8, "'Eat'"=>2, "'TV'"=>3, "'Gym'"=>4,"'Sleep'"=>9), "", "", "array",array("title" => "Employee Data","width"=>"500", "height"=>"500","google-chart-type"=>"AreaChart"));
                                echo $pdocrud->render("chart", array("chart1","chart2","chart3","chart4","chart5"));