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, ]);