Adding another chart option for lead sidebar widget as "Leads by Source "

By default there is QuickCharts sidebar widget as “Leads By Status” on list view of lead module, I want another option as “Leads by Source”. I have altered the Listview php of “public/legacy/custom/modules/Leads/metadata/listviewdefs.php”
and this created another option as lead by source.

but now how to create query and other things to show my chart there.

        $query = $this->queryHandler->getQuery($bean, $criteria, $sort);
        $query['select'] = 'SELECT leads.lead_source as name, count(*) as value';
        $query['order_by'] = '';
        $query['group_by'] = ' GROUP BY leads.lead_source ';