From 68d0449f8061d735f59ece9eab8bfe930ebbf60a Mon Sep 17 00:00:00 2001 From: Hjj <126586545@qq.com> Date: Wed, 25 Jun 2025 23:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=84=E6=8A=A5=E5=88=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A6=82=E8=A7=88js=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Examples/Follow/AllEnrollCollege.php | 9 +++++++- .../Examples/Follow/AllEnrollSpeciality.php | 23 ++++++++----------- .../Examples/Follow/AllNewFollowCollege.php | 11 +++++---- .../Follow/AllNewFollowSpeciality.php | 11 +++++---- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php b/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php index ec27f15..88c7cc6 100644 --- a/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php +++ b/app/Admin/Metrics/Examples/Follow/AllEnrollCollege.php @@ -64,8 +64,15 @@ class AllEnrollCollege extends Round // 女生 $girl = $all[2] ?? 0; - $this->chartLabels(['总人数', '男生', '女生']); + $manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0; + $girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0; + // 卡片内容 $this->withContent($total, $man, $girl)->height('220px'); + $this->chartLabels(['男生', '女生']); + // 图表数据 + $this->withChart([$manPercent, $girlPercent]); + // 总数 + $this->chartTotal('总人数', $total); } diff --git a/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php b/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php index ddf0951..292af53 100644 --- a/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php +++ b/app/Admin/Metrics/Examples/Follow/AllEnrollSpeciality.php @@ -66,8 +66,15 @@ class AllEnrollSpeciality extends Round // 女生 $girl = $all[2] ?? 0; - $this->chartLabels(['总人数', '男生', '女生']); - $this->withContent($total, $man, $girl); + $manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0; + $girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0; + // 卡片内容 + $this->withContent($total, $man, $girl)->height('220px'); + $this->chartLabels(['男生', '女生']); + // 图表数据 + $this->withChart([$manPercent, $girlPercent]); + // 总数 + $this->chartTotal('总人数', $total); } @@ -86,18 +93,6 @@ class AllEnrollSpeciality extends Round } - /** - * @param int $percent - * - * @return $this - */ - public function up($percent) - { - return $this->footer( - " {$percent}人 为当前年份已导入新生人数" - ); - } - /** * 卡片内容. * diff --git a/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php b/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php index 214dc64..385cae5 100644 --- a/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php +++ b/app/Admin/Metrics/Examples/Follow/AllNewFollowCollege.php @@ -76,12 +76,15 @@ class AllNewFollowCollege extends Round // 女生 $girl = $all[2] ?? 0; + $manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0; + $girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0; + // 卡片内容 + $this->withContent($total, $man, $girl)->height('220px'); + $this->chartLabels(['男生', '女生']); // 图表数据 - $this->withChart([$man, $girl]); + $this->withChart([$manPercent, $girlPercent]); // 总数 - $this->chartTotal('总人数', $girl + $man); - // 卡片内容 - $this->withContent($girl + $man, $man, $girl)->height('220px'); + $this->chartTotal('总人数', $total); } diff --git a/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php b/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php index c97618b..b206aa9 100644 --- a/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php +++ b/app/Admin/Metrics/Examples/Follow/AllNewFollowSpeciality.php @@ -61,12 +61,15 @@ class AllNewFollowSpeciality extends Round // 女生 $girl = $all[2] ?? 0; + $manPercent = $total != 0 ? number_format(($man /$total) * 100) : 0; + $girlPercent = $total != 0 ? number_format(($girl / $total) * 100) : 0; + // 卡片内容 + $this->withContent($total, $man, $girl)->height('220px'); + $this->chartLabels(['男生', '女生']); // 图表数据 - $this->withChart([$man, $girl]); + $this->withChart([$manPercent, $girlPercent]); // 总数 $this->chartTotal('总人数', $total); - // 卡片内容 - $this->withContent($total, $man, $girl); } @@ -77,7 +80,7 @@ class AllNewFollowSpeciality extends Round */ public function withChart(array $data) { - $this->chartColors(['#586cb1', '#dda451', '#ea5455']); + $this->chartColors(['#dda451', '#ea5455']); return $this->chart([ 'series' => $data, ]);