调整气象图
parent
c5f6578377
commit
172c6fe895
|
|
@ -97,6 +97,7 @@ class Components extends BaseRenderer {
|
|||
public function chartLineBarConfig($title = '', array $x , array $y){
|
||||
$yAxisData = [];
|
||||
$seriesData = [];
|
||||
$color = [];
|
||||
if(!isset($y[0])){
|
||||
$_y = $y;
|
||||
$y = [0=>$_y];
|
||||
|
|
@ -104,11 +105,13 @@ class Components extends BaseRenderer {
|
|||
$i = 0;
|
||||
$tips = '{b0}';
|
||||
foreach($y as $item) {
|
||||
//调色盘
|
||||
$color[] = $item['color'];
|
||||
//tips
|
||||
$tips.= '<br/> {a'.$i.'}: {c'.$i.'}'.($item['unit'] ?? '');
|
||||
//纵坐标
|
||||
$yAxisData[] = [
|
||||
'name'=>$item['name'].($item['unit'] ?? ''),
|
||||
'name'=>($item['unit'] ?? ''),
|
||||
'type' =>'value',
|
||||
'axisTick' => true,
|
||||
'alignTicks' => true,
|
||||
|
|
@ -119,7 +122,7 @@ class Components extends BaseRenderer {
|
|||
]
|
||||
],
|
||||
'axisLabel'=> [
|
||||
'formatter'=>'{value} '.($item['unit'] ?? '')
|
||||
'formatter'=>'{value} '
|
||||
]
|
||||
];
|
||||
//数据
|
||||
|
|
@ -143,6 +146,8 @@ class Components extends BaseRenderer {
|
|||
]);
|
||||
break;
|
||||
case 'bar':
|
||||
$_series = array_merge($_series, [
|
||||
]);
|
||||
break;
|
||||
}
|
||||
$seriesData[] = $_series;
|
||||
|
|
@ -150,6 +155,7 @@ class Components extends BaseRenderer {
|
|||
}
|
||||
|
||||
return [
|
||||
'color' => $color,
|
||||
'title' => [
|
||||
'text' => $title,
|
||||
],
|
||||
|
|
@ -172,6 +178,52 @@ class Components extends BaseRenderer {
|
|||
'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
|
||||
|
|
|
|||
|
|
@ -142,9 +142,45 @@ class DeviceService extends BaseService
|
|||
$k++;
|
||||
|
||||
//特殊字段,特殊统计图;
|
||||
switch($field){
|
||||
//点状图;-todo
|
||||
//柱状图;-todo
|
||||
switch($key){
|
||||
//点状图;
|
||||
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://折线图
|
||||
$_chartCard = amisMake()->Card()->body(
|
||||
amisMake()->Chart()->config(
|
||||
|
|
|
|||
Loading…
Reference in New Issue