调整气象图
parent
c5f6578377
commit
172c6fe895
|
|
@ -97,6 +97,7 @@ class Components extends BaseRenderer {
|
||||||
public function chartLineBarConfig($title = '', array $x , array $y){
|
public function chartLineBarConfig($title = '', array $x , array $y){
|
||||||
$yAxisData = [];
|
$yAxisData = [];
|
||||||
$seriesData = [];
|
$seriesData = [];
|
||||||
|
$color = [];
|
||||||
if(!isset($y[0])){
|
if(!isset($y[0])){
|
||||||
$_y = $y;
|
$_y = $y;
|
||||||
$y = [0=>$_y];
|
$y = [0=>$_y];
|
||||||
|
|
@ -104,11 +105,13 @@ class Components extends BaseRenderer {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$tips = '{b0}';
|
$tips = '{b0}';
|
||||||
foreach($y as $item) {
|
foreach($y as $item) {
|
||||||
|
//调色盘
|
||||||
|
$color[] = $item['color'];
|
||||||
//tips
|
//tips
|
||||||
$tips.= '<br/> {a'.$i.'}: {c'.$i.'}'.($item['unit'] ?? '');
|
$tips.= '<br/> {a'.$i.'}: {c'.$i.'}'.($item['unit'] ?? '');
|
||||||
//纵坐标
|
//纵坐标
|
||||||
$yAxisData[] = [
|
$yAxisData[] = [
|
||||||
'name'=>$item['name'].($item['unit'] ?? ''),
|
'name'=>($item['unit'] ?? ''),
|
||||||
'type' =>'value',
|
'type' =>'value',
|
||||||
'axisTick' => true,
|
'axisTick' => true,
|
||||||
'alignTicks' => true,
|
'alignTicks' => true,
|
||||||
|
|
@ -119,7 +122,7 @@ class Components extends BaseRenderer {
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'axisLabel'=> [
|
'axisLabel'=> [
|
||||||
'formatter'=>'{value} '.($item['unit'] ?? '')
|
'formatter'=>'{value} '
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
//数据
|
//数据
|
||||||
|
|
@ -143,6 +146,8 @@ class Components extends BaseRenderer {
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case 'bar':
|
case 'bar':
|
||||||
|
$_series = array_merge($_series, [
|
||||||
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$seriesData[] = $_series;
|
$seriesData[] = $_series;
|
||||||
|
|
@ -150,6 +155,7 @@ class Components extends BaseRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'color' => $color,
|
||||||
'title' => [
|
'title' => [
|
||||||
'text' => $title,
|
'text' => $title,
|
||||||
],
|
],
|
||||||
|
|
@ -172,6 +178,52 @@ class Components extends BaseRenderer {
|
||||||
'series' => $seriesData
|
'series' => $seriesData
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 散点图
|
||||||
|
*/
|
||||||
|
public function chartScatterConfig($title = '', array $x , array $y, array $yData = null){
|
||||||
|
$yAxisData = [];
|
||||||
|
$seriesData = [];
|
||||||
|
$color = [];
|
||||||
|
|
||||||
|
if($yData){
|
||||||
|
$yAxisData = [
|
||||||
|
'type' =>'category',
|
||||||
|
// 'splitLine'=>[
|
||||||
|
// 'show'=>true,
|
||||||
|
// 'lineStyle'=>[
|
||||||
|
// 'type'=>'dashed'
|
||||||
|
// ]
|
||||||
|
// ],
|
||||||
|
'axisTick' => [
|
||||||
|
'alignWithLabel'=>true
|
||||||
|
],
|
||||||
|
'data'=> $yData
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$seriesData = $y;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'color' => $color,
|
||||||
|
'title' => [
|
||||||
|
'text' => $title,
|
||||||
|
],
|
||||||
|
"tooltip" => [//提示
|
||||||
|
'trigger'=>'axis',//坐标轴触发
|
||||||
|
'axisPointer' => [
|
||||||
|
'type' => 'cross'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'xAxis' => [
|
||||||
|
'type' => 'category',
|
||||||
|
'data' => $x,
|
||||||
|
],
|
||||||
|
'yAxis' => $yAxisData,
|
||||||
|
'series' => $seriesData
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成饼状图config
|
* 生成饼状图config
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,45 @@ class DeviceService extends BaseService
|
||||||
$k++;
|
$k++;
|
||||||
|
|
||||||
//特殊字段,特殊统计图;
|
//特殊字段,特殊统计图;
|
||||||
switch($field){
|
switch($key){
|
||||||
//点状图;-todo
|
//点状图;
|
||||||
//柱状图;-todo
|
case 'wind_direction':
|
||||||
|
$yData = ['北风','东北风','东风','东南风','南风','西南风','西风','西北风'];
|
||||||
|
$_chartCard = amisMake()->Card()->body(
|
||||||
|
amisMake()->Chart()->config(
|
||||||
|
Components::make()->chartScatterConfig($field['name'], $xKeys,
|
||||||
|
[
|
||||||
|
'name'=> $field['name'],
|
||||||
|
'type' => 'scatter',
|
||||||
|
'symbolSize' => 15,
|
||||||
|
'data' => array_map(function($item)use($yData){
|
||||||
|
return $yData[$item];
|
||||||
|
},$field['data']),
|
||||||
|
'color' => '#91CC75',
|
||||||
|
], $yData
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
//柱状图;
|
||||||
|
case 'box_noise':
|
||||||
|
case 'pm10':
|
||||||
|
case 'pm25':
|
||||||
|
case 'box_co2':
|
||||||
|
$_chartCard = amisMake()->Card()->body(
|
||||||
|
amisMake()->Chart()->config(
|
||||||
|
Components::make()->chartLineBarConfig($field['name'], $xKeys, [
|
||||||
|
[
|
||||||
|
'name'=> $field['name'],
|
||||||
|
'type' => 'bar',
|
||||||
|
'data' => $field['data'],
|
||||||
|
'color' => '#91CC75',
|
||||||
|
'unit' => $field['unit']
|
||||||
|
]
|
||||||
|
])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
default://折线图
|
default://折线图
|
||||||
$_chartCard = amisMake()->Card()->body(
|
$_chartCard = amisMake()->Card()->body(
|
||||||
amisMake()->Chart()->config(
|
amisMake()->Chart()->config(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue