Original Source
https://pdocrud.com/demo/pages/google-chart
https://pdocrud.com/demo/pages/easy-pie-chart
https://pdocrud.com/demo/pages/sparkline-chart
Google Chart
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.
Line Chart, Bar Chart, Pie Chart, Donut Chart, 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"));
Easy Pie Chart
Add pie chart from database tables directly using PDO (Added in v 2.2)
Apart from plugin addition, you can using addChart function to generate pie 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 from database tables or write query. Below example shows how to add easy pie chart. Please note that each chart/graph library has it's own functions and parameters so you need to pass data accordingly.
$pdocrud = new PDOCrud();
//function defination of addChart($chartName, $chartType, $dataSource, $key, $val, $bind = "db", $param = array());
//pass value as array
$pdocrud->addChart("chart1", "easypie", array("val" => 93), "", "", "array");
//pass value as database table (similar to field binding)
$pdocrud->addChart("chart2", "easypie", "employee", "Id", "Id as empId", "db", array("animate" => "2000"));
//Pass value as sql query
$pdocrud->addChart("chart3", "easypie", "select count(*) as val from employee where `City`!=''", "", "", "sql", array("animate" => "100"));
echo $pdocrud->render("chart", array("chart1", "chart2", "chart3"));
Sparkline Chart
Add sparkline chart from database tables directly using PDO (Added in v 2.2)
Apart from plugin addition, you can using addChart function to generate pie 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 from database tables or write query. Below example shows how to add sparkline chart. Please note that each chart/graph library has it's own functions and parameters so you need to pass data accordingly.
$pdocrud = new PDOCrud();
$options_line = array("data-type"=>"line", "data-resize"=>"true", "data-height"=>"75", "data-width"=>"90%", "data-line-width"=>"1", "data-line-color"=>"#fff", "data-spot-color"=>"#fff", "data-fill-color"=>"", "data-highlight-line-color"=>"#fff", "data-spot-radius"=>"4");
$pdocrud->addChart("chart1","sparkline",array("val"=>93,34,34,34,533,434,213,23,23,23,23,23),"","","array",$options_line);
$options_bar = array("data-type"=>"bar", "data-resize"=>"true", "data-height"=>"75", "data-width"=>"90%", "data-line-width"=>"1", "data-line-color"=>"#fff", "data-spot-color"=>"#fff", "data-fill-color"=>"", "data-highlight-line-color"=>"#fff", "data-spot-radius"=>"4");
$pdocrud->addChart("chart2","sparkline",array("val"=>93,34,34,34,533,434,213,23,23,23,23,23),"","","array",$options_bar);
$options_pie = array("data-type"=>"pie", "data-resize"=>"true", "data-height"=>"75", "data-width"=>"90%", "data-line-width"=>"1", "data-line-color"=>"#fff", "data-spot-color"=>"#fff", "data-fill-color"=>"", "data-highlight-line-color"=>"#fff", "data-spot-radius"=>"4");
$pdocrud->addChart("chart3","sparkline", "employee", "Id", "Id as empId", "db",$options_pie);
$options_line = array("data-type"=>"line", "data-resize"=>"true", "data-height"=>"75", "data-width"=>"90%", "data-line-width"=>"1", "data-line-color"=>"#fff", "data-spot-color"=>"#fff", "data-fill-color"=>"", "data-highlight-line-color"=>"#fff", "data-spot-radius"=>"4");
$pdocrud->addChart("chart4","sparkline","SELECT Salary FROM `empsalary` ", "", "", "sql",$options_line);
echo $pdocrud->render("chart",array("chart1","chart2","chart3","chart4"));