浏览代码

图表升级

jqh 5 年之前
父节点
当前提交
1c1ae1bc54

文件差异内容过多而无法显示
+ 0 - 27519
resources/assets/vendors/js/charts/apexcharts.js


文件差异内容过多而无法显示
+ 0 - 5
resources/assets/vendors/js/charts/apexcharts.min.js


文件差异内容过多而无法显示
+ 0 - 27519
resources/dist/vendors/js/charts/apexcharts.js


文件差异内容过多而无法显示
+ 0 - 5
resources/dist/vendors/js/charts/apexcharts.min.js


+ 0 - 1
src/Console/stubs/metrics/ProductOrders.stub

@@ -15,7 +15,6 @@ class ProductOrders extends RoundChartCard
         parent::init();
 
         $this->title('Product Orders');
-        $this->height(180);
         $this->chartLabels(['Finished', 'Pending', 'Rejected']);
         $this->dropdown([
             '7' => 'Last 7 Days',

+ 1 - 5
src/Console/stubs/metrics/Sessions.stub

@@ -37,10 +37,6 @@ class Sessions extends BarChartCard
         $dark35 = $color->dark35();
 
         $this->title('Avg Sessions');
-        // 设置卡片高度,可以不设置
-        $this->height(280);
-        // 设置图表高度
-        $this->chartHeight(200);
         // 设置下拉选项
         $this->dropdown($this->dropdownItems);
         // 设置图表颜色
@@ -109,7 +105,7 @@ class Sessions extends BarChartCard
             $this->dropdownItems[request()->option] ?? 'last 7 days'
         );
 
-        $minHeight = '200px';
+        $minHeight = '188px';
 
         return $this->content(
             <<<HTML

+ 2 - 2
src/Console/stubs/metrics/Tickets.stub

@@ -15,8 +15,8 @@ class Tickets extends RadialBarChartCard
         parent::init();
 
         $this->title('Tickets');
-        $this->height(380);
-        $this->chartHeight(270);
+        $this->height(400);
+        $this->chartHeight(275);
         $this->chartLabels('Completed Tickets');
         $this->dropdown([
             '7' => 'Last 7 Days',

+ 1 - 1
src/Layout/Asset.php

@@ -169,7 +169,7 @@ class Asset
             'js' => '@admin/dcat/plugins/input-mask/jquery.inputmask.bundle.min.js',
         ],
         '@apex-charts' => [
-            'js' => '@admin/vendors/js/charts/apexcharts.min.js',
+            'js' => '@admin/vendors/js/charts/apexcharts.js',
         ],
         '@smart-wizard' => [
             'js' => '@admin/dcat/plugins/SmartWizard/dist/js/jquery.smartWizard.min.js',

+ 0 - 7
src/Widgets/Metrics/BarChartCard.php

@@ -20,13 +20,6 @@ class BarChartCard extends RadialBarChartCard
      */
     protected $chartHeight = 180;
 
-    /**
-     * 图表下间距.
-     *
-     * @var int
-     */
-    protected $chartMarginBottom = 0;
-
     /**
      * 图表位置是否靠右.
      *

+ 64 - 0
src/Widgets/Metrics/Card.php

@@ -52,6 +52,20 @@ class Card extends Widget
      */
     protected $chartHeight = 70;
 
+    /**
+     * 图表上间距.
+     *
+     * @var int
+     */
+    protected $chartMarginTop;
+
+    /**
+     * 图表下间距.
+     *
+     * @var int
+     */
+    protected $chartMarginBottom;
+
     /**
      * 图表配置.
      *
@@ -255,6 +269,38 @@ class Card extends Widget
         return $this;
     }
 
+    /**
+     * 设置图表上间距.
+     *
+     * @param int $number
+     *
+     * @return $this
+     */
+    public function chartMarginTop(int $number)
+    {
+        $this->chartMarginBottom = $number;
+
+        $this->useChart();
+
+        return $this;
+    }
+
+    /**
+     * 设置图表下间距.
+     *
+     * @param int $number
+     *
+     * @return $this
+     */
+    public function chartMarginBottom(int $number)
+    {
+        $this->chartMarginBottom = $number;
+
+        $this->useChart();
+
+        return $this;
+    }
+
     /**
      * 设置图表label.
      *
@@ -319,6 +365,8 @@ class Card extends Widget
             return;
         }
 
+        $this->setUpChartMargin();
+
         // 设置图表高度
         $this->chartOptions['chart']['height'] = $this->chartHeight;
 
@@ -335,6 +383,22 @@ class Card extends Widget
         }
     }
 
+    /**
+     * 设置图表间距.
+     *
+     * @return void
+     */
+    protected function setUpChartMargin()
+    {
+        if ($this->chartMarginTop !== null) {
+            $this->chart->style("margin-top: {$this->chartMarginTop}px;");
+        }
+
+        if ($this->chartMarginBottom !== null) {
+            $this->chart->style("margin-bottom: {$this->chartMarginBottom}px;");
+        }
+    }
+
     /**
      * @return mixed
      */

+ 1 - 1
src/Widgets/Metrics/DonutChartCard.php

@@ -9,7 +9,7 @@ class DonutChartCard extends Card
     /**
      * @var int
      */
-    protected $chartHeight = 128;
+    protected $chartHeight = 100;
 
     /**
      * 内容宽度.

+ 4 - 13
src/Widgets/Metrics/RadialBarChartCard.php

@@ -41,13 +41,6 @@ class RadialBarChartCard extends Card
      */
     protected $contentWidth = [2, 10];
 
-    /**
-     * 图表下间距.
-     *
-     * @var int
-     */
-    protected $chartMarginBottom = -10;
-
     /**
      * 图表位置是否靠右.
      *
@@ -63,8 +56,6 @@ class RadialBarChartCard extends Card
         parent::init();
 
         $this->useChart();
-
-        $this->chart->style("margin-bottom: {$this->chartMarginBottom}px;");
     }
 
     /**
@@ -83,10 +74,10 @@ class RadialBarChartCard extends Card
             ],
             'plotOptions' => [
                 'radialBar' => [
-                    'size' => 150,
-                    'startAngle' => -150,
-                    'endAngle' => 150,
-                    'offsetY' => 20,
+                    'size' => 200,
+                    'startAngle' => -180,
+                    'endAngle' => 175,
+                    'offsetY' => 0,
                     'hollow' => [
                         'size' => '65%',
                     ],

+ 10 - 3
src/Widgets/Metrics/RoundChartCard.php

@@ -31,7 +31,7 @@ class RoundChartCard extends RadialBarChartCard
      *
      * @var int
      */
-    protected $chartHeight = 230;
+    protected $chartHeight = 210;
 
     /**
      * 内容宽度.
@@ -40,12 +40,19 @@ class RoundChartCard extends RadialBarChartCard
      */
     protected $contentWidth = [5, 7];
 
+    /**
+     * 图表上间距.
+     *
+     * @var int
+     */
+    protected $chartMarginTop = -10;
+
     /**
      * 图表下间距.
      *
      * @var int
      */
-    protected $chartMarginBottom = -40;
+    protected $chartMarginBottom = -20;
 
     /**
      * 图表默认配置.
@@ -68,7 +75,7 @@ class RoundChartCard extends RadialBarChartCard
             ],
             'plotOptions' => [
                 'radialBar' => [
-                    'size' => 100,
+                    'size' => 90,
                     'hollow' => [
                         'size' => '20%',
                     ],

部分文件因为文件数量过多而无法显示