SingleRound.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Dcat\Admin\Widgets\Metrics;
  3. use Dcat\Admin\Admin;
  4. /**
  5. * 单环形图卡片.
  6. *
  7. * Class SingleRound
  8. */
  9. class SingleRound extends Round
  10. {
  11. /**
  12. * 图表下间距.
  13. *
  14. * @var int
  15. */
  16. protected $chartMarginBottom = 5;
  17. /**
  18. * 图表默认配置.
  19. *
  20. * @return array
  21. */
  22. protected function defaultChartOptions()
  23. {
  24. $color = Admin::color();
  25. $colors = [$color->success()];
  26. $gradientToColors = [$color->tear1()];
  27. $strokColor = $color->gray();
  28. return [
  29. 'chart' => [
  30. 'type' => 'radialBar',
  31. 'sparkline' => [
  32. 'enabled' => true,
  33. ],
  34. 'dropShadow' => [
  35. 'enabled' => true,
  36. 'blur' => 3,
  37. 'left' => 1,
  38. 'top' => 1,
  39. 'opacity' => 0.1,
  40. ],
  41. ],
  42. 'colors' => $colors,
  43. 'plotOptions' => [
  44. 'radialBar' => [
  45. 'size' => 70,
  46. 'startAngle' => -180,
  47. 'endAngle' => 179,
  48. 'hollow' => [
  49. 'size' => '74%',
  50. ],
  51. 'track' => [
  52. 'background' => $strokColor,
  53. 'strokeWidth' => '50%',
  54. ],
  55. 'dataLabels' => [
  56. 'name' => [
  57. 'show' => false,
  58. ],
  59. 'value' => [
  60. 'offsetY' => 14,
  61. 'color' => $strokColor,
  62. 'fontSize' => '2.8rem',
  63. ],
  64. ],
  65. ],
  66. ],
  67. 'fill' => [
  68. 'type' => 'gradient',
  69. 'gradient' => [
  70. 'shade' => 'dark',
  71. 'type' => 'horizontal',
  72. 'shadeIntensity' => 0.5,
  73. 'gradientToColors' => $gradientToColors,
  74. 'inverseColors' => true,
  75. 'opacityFrom' => 1,
  76. 'opacityTo' => 1,
  77. 'stops' => [0, 100],
  78. ],
  79. ],
  80. 'series' => [100],
  81. 'stroke' => [
  82. 'lineCap' => 'round',
  83. ],
  84. ];
  85. }
  86. }