我想在dynamic chart
jQuery 的帮助下创建一个。我想在图表中传递label
这value
两个数组。我怎样才能做到这一点?
这是控制器功能:
public function chart()
{
$govtRecievablesStatus = DB::select("select LABEL,round(sum(value)/1000000,1) value from (
select null as link,LABEL,value from (
select * from (
select case when 'ALL'='ALL' then 'ALL' else COMPANY end as link, LABEL,sum(VALUE) value from(
select * from APEX_BI_GOVT_RCV_V)
group by case when 'ALL'='ALL' then 'ALL' else COMPANY end,LABEL
)
where link='ALL')
union all
select * from (
select null as link,'Not Yet due for Filing' label,round(SUM(REBATE_AMOUNT)) value
from xx_rebate_refund
where org_id = 10
and status = 'NOT_REALIZE')
where 'AL
L' in ('USD','ALL'))
group by LABEL");
$label=[];
foreach($govtRecievablesStatus as $gs){
$label[] = $gs->label;
}
// return $label;
$value= [];
foreach($govtRecievablesStatus as $gs){
$value[] = $gs->value;
}
// return $value;
$data = array(
'label' => $label,
'value' => $value
);
// return $data;
return view('governmentreceivables::dashboard')->with($data);
}
这是jQuery代码:
$(document).ready(function() {
// console.log("Hello")
var e = {
chart: {
width: "100%",
type: "pie"
},
ajax: function() {
var urlPath = 'http://' + window.location.hostname + '/dashboard';
var request = $.ajax({
method: 'GET',
url: urlPath,
});
request.done(function(response) {
console.log(response);
})
},
// obj =
// o.labels ;
// o.values
labels: labels,
value: value,
// series:[44,55,13,43,22],
legend: {
position: "bottom"
},
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 300
},
legend: {
position: "bottom",
offsetY: 40
}
}
}]
};
(t = new ApexCharts(document.querySelector("#simplePie"), e)).render()
});
请帮忙谢谢。