+
\${w.config.labels[dataPointIndex]}
+
+
+
+
+
+ \${w.config.series[0].name}: \${w.config.series[0].data[dataPointIndex]}
+
+
+ \${newStr}
+
+ `;
+}
+JS;
+
+ $this->option('tooltip.custom', JavaScript::make($tooltipCustomFunction));
+ }
+
+ /**
+ * 这里返回需要异步传递到 handler 方法的参数
+ *
+ * @return array
+ */
+ public function parameters(): array
+ {
+ return [
+ 'id' => $this->id,
+ 'username' => $this->username,
+ ];
+ }
+
+ /**
+ * 这里覆写父类的方法,不再查询数据
+ */
+ protected function buildData()
+ {
+ }
+}
diff --git a/app/Admin/Metrics/Examples/Follow/AllCollegesCharts.php b/app/Admin/Metrics/Examples/Follow/AllCollegesCharts.php
index fa81cbf..60632dc 100644
--- a/app/Admin/Metrics/Examples/Follow/AllCollegesCharts.php
+++ b/app/Admin/Metrics/Examples/Follow/AllCollegesCharts.php
@@ -3,9 +3,7 @@
namespace App\Admin\Metrics\Examples\Follow;
use App\Models\AdmissionNewStudents;
-use App\Models\CompletedOfflineStep;
use App\Models\Config;
-use App\Models\OfflineStep;
use App\Models\SecondaryCollege;
use App\Models\Speciality;
use App\Models\UsersMember;
@@ -15,7 +13,7 @@ use Illuminate\Support\Facades\DB;
class AllCollegesCharts extends Chart
{
- //各二级学院女生报道率
+ // 各学院新生录取统计
public function __construct($containerSelector = null, $options = [])
{
parent::__construct($containerSelector, $options);
@@ -29,7 +27,7 @@ class AllCollegesCharts extends Chart
{
$this->options([
"chart"=>[
- "height"=>300, //高度
+ "height"=>330, //高度
"type"=>"bar", //chart 类型
],
]);
@@ -101,7 +99,6 @@ class AllCollegesCharts extends Chart
}
}
-
$this->option("series",$data);
$this->option("labels",$label);
$this->option("yaxis",["max" => 2000]); //Y轴最大值
diff --git a/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php b/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php
new file mode 100644
index 0000000..568cd86
--- /dev/null
+++ b/app/Admin/Metrics/Examples/Follow/AllCollegesFollowCharts.php
@@ -0,0 +1,86 @@
+setUpOptions();
+ }
+
+ /**
+ * 初始化图表配置
+ */
+ protected function setUpOptions()
+ {
+ $color = Admin::color();
+
+ $colors = [$color->primary(), $color->primaryDarker()];
+
+ $this->options([
+ 'colors' => ['#008ffbd9', '#feb019', '#00e396'],
+ 'chart' => [
+ 'type' => 'bar',
+ "height"=>'315px', //高度
+ ],
+ 'plotOptions' => [
+ 'bar' => [
+ 'horizontal' => false,
+ 'columnWidth' => '80%',
+ 'borderRadius' => 5,
+ 'borderRadiusApplication' => 'end'
+ ]
+ ],
+ 'stroke' => [
+ 'show' => false,
+ 'width' => 3
+ ],
+ 'xaxis' => [
+ 'type' => 'category',
+ ],
+ 'tooltip' => [
+ 'x' => [
+ 'formatter' => function ($val) {
+ return $val;
+ }
+ ]
+ ],
+ ]);
+ }
+
+
+ /**
+ * 设置图表数据
+ * @param array $data
+ * @return $this
+ */
+ public function withData(array $data)
+ {
+ return $this->option('series', $data);
+ }
+
+ /**
+ * 设置图表类别.
+ * @param array $data
+ * @return $this
+ */
+ public function withCategories(array $data)
+ {
+ return $this->option('xaxis.categories', $data);
+ }
+
+ /**
+ * 渲染图表
+ * @return string
+ */
+ public function render()
+ {
+ return parent::render();
+ }
+}