|
|
@@ -140,19 +140,36 @@ class FarmMetricsController extends AdminController
|
|
|
6 => '紫色特殊土地',
|
|
|
];
|
|
|
|
|
|
- // 构建图表数据
|
|
|
+ // 构建图表数据 - 只显示有数据的土地类型
|
|
|
$series = [];
|
|
|
$colors = ['#6c757d', '#dc3545', '#343a40', '#ffc107', '#007bff', '#17a2b8'];
|
|
|
-
|
|
|
+ $legendData = [];
|
|
|
+
|
|
|
for ($type = 1; $type <= 6; $type++) {
|
|
|
- $series[] = [
|
|
|
- 'name' => $landTypeNames[$type],
|
|
|
- 'type' => 'line',
|
|
|
- 'data' => $landData[$type],
|
|
|
- 'itemStyle' => [
|
|
|
- 'color' => $colors[$type - 1]
|
|
|
- ]
|
|
|
- ];
|
|
|
+ // 检查是否有非零数据
|
|
|
+ $hasData = array_sum($landData[$type]) > 0;
|
|
|
+ if ($hasData) {
|
|
|
+ $series[] = [
|
|
|
+ 'name' => $landTypeNames[$type],
|
|
|
+ 'type' => 'line',
|
|
|
+ 'data' => $landData[$type],
|
|
|
+ 'smooth' => true, // 平滑曲线
|
|
|
+ 'symbol' => 'circle', // 数据点样式
|
|
|
+ 'symbolSize' => 6, // 数据点大小
|
|
|
+ 'lineStyle' => [
|
|
|
+ 'width' => 3, // 线条宽度
|
|
|
+ 'color' => $colors[$type - 1]
|
|
|
+ ],
|
|
|
+ 'itemStyle' => [
|
|
|
+ 'color' => $colors[$type - 1]
|
|
|
+ ],
|
|
|
+ 'areaStyle' => [
|
|
|
+ 'opacity' => 0.1, // 添加半透明填充区域
|
|
|
+ 'color' => $colors[$type - 1]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $legendData[] = $landTypeNames[$type];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$chartId = 'land-trends-chart';
|
|
|
@@ -169,8 +186,11 @@ class FarmMetricsController extends AdminController
|
|
|
trigger: 'axis'
|
|
|
},
|
|
|
legend: {
|
|
|
- data: ['" . implode("','", array_values($landTypeNames)) . "'],
|
|
|
- top: 30
|
|
|
+ data: ['" . implode("','", $legendData) . "'],
|
|
|
+ top: 30,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 12
|
|
|
+ }
|
|
|
},
|
|
|
grid: {
|
|
|
left: '3%',
|
|
|
@@ -184,7 +204,17 @@ class FarmMetricsController extends AdminController
|
|
|
data: ['" . implode("','", $dates) . "']
|
|
|
},
|
|
|
yAxis: {
|
|
|
- type: 'value'
|
|
|
+ type: 'value',
|
|
|
+ name: '数量(块)',
|
|
|
+ nameLocation: 'middle',
|
|
|
+ nameGap: 50,
|
|
|
+ min: 0,
|
|
|
+ splitLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ type: 'dashed'
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
series: " . json_encode($series) . "
|
|
|
};
|