8 months ago

ConsoleTV Chartjs chart type

Posted 8 months ago by kshitizmittal

I am using this below package for charts.


This is the class I made for charts,


namespace App\Charts;

use ConsoleTVs\Charts\Classes\Chartjs\Chart;

class UserChart extends Chart
     * Initializes the chart.
     * @return void
    public function __construct()

This is how I made object in controller,

    public function index()
        $users = Employeedetail::with(['officelocations','departments','designations','subdepartments'])->where(['status'=>'Active'])->get();

        $graphData = DB::select("SELECT result.childdepartment as label, count(result.id) as value from (select ed.id, ed.emp_id, dept.parentdepartment, dept.childdepartment from employeedetails as ed LEFT JOIN (select child_dept.deptid as id, child_dept.deptname as childdepartment, parent_dept.deptname as parentdepartment from departments as parent_dept INNER JOIN departments as child_dept on child_dept.deptparent = parent_dept.deptid) as dept on ed.department = dept.id) as result GROUP BY childdepartment");

        $chart = new UserChart;
        $chart->labels(['One', 'Two', 'Three', 'Four']);
        $chart->dataset('My dataset', 'line', [1, 2, 3, 4]);
        $chart->dataset('My dataset 2', 'doughnut', [4, 3, 2, 1]);
            'tooltip' => [
                'show' => true // or false, depending on what you want.

        return view('eno.user',compact('users','departments','designations','officelocations','graphData','chart'));

My concern is how I can change the chart type ??

Please sign in or create an account to participate in this conversation.