<?php
function
getStatData_LineLabels(
$stat_arr
){
$stat_arr
['chart']['type'] = 'line';
$stat_arr
['colors']?'':
$stat_arr
['colors'] =
array
('#058DC7', '#ED561B', '#8bbc21', '#0d233a');
$stat_arr
['credits']['enabled'] = false;
$stat_arr
['exporting']['enabled'] = false;
is_string
(
$stat_arr
['title'])?
$stat_arr
['title'] =
array
('text'=>
"<b>{$stat_arr['title']}</b>"
,'x'=>-20):'';
is_string
(
$stat_arr
['subtitle'])?
$stat_arr
['subtitle'] =
array
('text'=>
"<b>{$stat_arr['subtitle']}</b>"
,'x'=>-20):'';
if
(
is_string
(
$stat_arr
['yAxis'])){
$text
=
$stat_arr
['yAxis'];
unset(
$stat_arr
['yAxis']);
$stat_arr
['yAxis']['title']['text'] =
$text
;
}
return
json_encode(
$stat_arr
);
}
function
getStatData_Column2D(
$stat_arr
){
$stat_arr
['chart']['type'] = 'column';
$stat_arr
['credits']['enabled'] = false;
$stat_arr
['exporting']['enabled'] = false;
is_string
(
$stat_arr
['title'])?
$stat_arr
['title'] =
array
('text'=>
"<b>{$stat_arr['title']}</b>"
,'x'=>-20):'';
is_string
(
$stat_arr
['subtitle'])?
$stat_arr
['subtitle'] =
array
('text'=>
"<b>{$stat_arr['subtitle']}</b>"
,'x'=>-20):'';
if
(
is_string
(
$stat_arr
['yAxis'])){
$text
=
$stat_arr
['yAxis'];
unset(
$stat_arr
['yAxis']);
$stat_arr
['yAxis']['title']['text'] =
$text
;
}
$color
=
array
('#7a96a4','#cba952','#667b16','#a26642','#349898','#c04f51','#5c315e','#445a2b','#adae50','#14638a','#b56367','#a399bb','#070dfa','#47ff07','#f809b7');
foreach
(
$stat_arr
['series']
as
$series_k
=>
$series_v
){
foreach
(
$series_v
['data']
as
$data_k
=>
$data_v
){
$data_v
['color'] =
$color
[
$data_k
];
$series_v
['data'][
$data_k
] =
$data_v
;
}
$stat_arr
['series'][
$series_k
]['data'] =
$series_v
['data'];
}
return
json_encode(
$stat_arr
);
}
function
getStatData_Basicbar(
$stat_arr
){
$stat_arr
['chart']['type'] = 'bar';
$stat_arr
['credits']['enabled'] = false;
$stat_arr
['exporting']['enabled'] = false;
$stat_arr
['plotOptions']['bar']['dataLabels']['enabled'] = true;
is_string
(
$stat_arr
['title'])?
$stat_arr
['title'] =
array
('text'=>
"<b>{$stat_arr['title']}</b>"
,'x'=>-20):'';
is_string
(
$stat_arr
['subtitle'])?
$stat_arr
['subtitle'] =
array
('text'=>
"<b>{$stat_arr['subtitle']}</b>"
,'x'=>-20):'';
if
(
is_string
(
$stat_arr
['yAxis'])){
$text
=
$stat_arr
['yAxis'];
unset(
$stat_arr
['yAxis']);
$stat_arr
['yAxis']['title']['text'] =
$text
;
}
$color
=
array
('#7a96a4','#cba952','#667b16','#a26642','#349898','#c04f51','#5c315e','#445a2b','#adae50','#14638a','#b56367','#a399bb','#070dfa','#47ff07','#f809b7');
foreach
(
$stat_arr
['series']
as
$series_k
=>
$series_v
){
foreach
(
$series_v
['data']
as
$data_k
=>
$data_v
){
if
(!
$data_v
['color']){
$data_v
['color'] =
$color
[
$data_k
%15];
}
$series_v
['data'][
$data_k
] =
$data_v
;
}
$stat_arr
['series'][
$series_k
]['data'] =
$series_v
['data'];
}
return
json_encode(
$stat_arr
);
}
function
getHb(
$updata
,
$currentdata
){
if
(
$updata
!= 0){
$mtomrate
=
round
((
$currentdata
-
$updata
)/
$updata
*100, 2).'%';
}
else
{
$mtomrate
= '-';
}
return
$mtomrate
;
}
function
getTb(
$updata
,
$currentdata
){
if
(
$updata
!= 0){
$ytoyrate
=
round
((
$currentdata
-
$updata
)/
$updata
*100, 2).'%';
}
else
{
$ytoyrate
= '-';
}
return
$ytoyrate
;
}
function
getStatData_Map(
$stat_arr
){
$color_arr
=
array
('#fd0b07','#ff9191','#f7ba17','#fef406','#25aae2');
$stat_arrnew
=
array
();
foreach
(
$stat_arr
as
$k
=>
$v
){
$stat_arrnew
[] =
array
('cha'=>
$v
['cha'],'name'=>
$v
['name'],'des'=>
$v
['des'],'color'=>
$color_arr
[
$v
['level']]);
}
return
json_encode(
$stat_arrnew
);
}
function
getStatData_Pie(
$data
){
$stat_arr
['chart']['type'] = 'pie';
$stat_arr
['credits']['enabled'] = false;
$stat_arr
['title']['text'] =
$data
['title'];
$stat_arr
['tooltip']['pointFormat'] = '{series.name}: <b>{point.y}</b>';
$stat_arr
['plotOptions']['pie'] =
array
(
'allowPointSelect'=>true,
'cursor'=>'pointer',
'dataLabels'=>
array
(
'enabled'=>
$data
['label_show'],
'color'=>'#000000',
'connectorColor'=>'#000000',
'format'=>'<b>{point.name}</b>: {point.percentage:.1f} %'
)
);
$stat_arr
['series'][0]['name'] =
$data
['name'];
$stat_arr
['series'][0]['data'] =
array
();
foreach
(
$data
['series']
as
$k
=>
$v
){
$stat_arr
['series'][0]['data'][] =
array
(
$v
['p_name'],
$v
['allnum']);
}
return
json_encode(
$stat_arr
);
}