Level 70
Just check out this series-
i had a problem using highchart(piehart) in laravel which is to pass the array using json. mostly examples on internet are using single data. one pie chart using many query to filter specific category. but i want to pass array from one query which contain all category and total count for each category. can you guys show me how.
this my javascript in blade
<script type="text/javascript">
$(function () {
Highcharts.setOptions({
colors: ['#e7505a', '#f1c40f', '#2ecc71', '#2c3e50', '#32c5d2', '#d35400', '#8e44ad', '#7f8c8d']
});
// Build the senarai hitam chart
$('#hitam1').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Statistik Mengikut Pecahan Senarai Hitam'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.y:,.0f}</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Jumlah',
colorByPoint: true,
data: []
}]
}
$.getJSON("{{URL::to('/senaraihitamindividu')}}", function(json) {
if ( json.length != 0 ){
options.series[0].data = json;
chart = new Highcharts.Chart(options);
} else {
Tiada Rekod
}
});
});
this my route
Route::get('/senaraihitamindividu', 'DashboardController@hitamindividu');
this my controller
public function hitamindividu()
{
$jumLelaki = MpsUmum::selectRaw('jantina ,count(jantina) as user_count')
->where('is_deleted',0)
->where('kfg_jenis_umum_id',1)
->distinct('jantina')
->groupBy('jantina')
->get();
$jantina = $jumLelaki->jantina;
$user_count = $jumLelaki->user_count;
$response = array(
'status' => 'success',
'jantina' => $jantina,
'user_count' => $user_count
);
return Response::json($response);
}
Please or to participate in this conversation.