NumberS.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace UCore\DcatAdmin\Metrics\Examples;
  3. use Dcat\Admin\Widgets\Metrics\Card;
  4. use Dcat\Admin\Widgets\Metrics\RadialBar;
  5. use Illuminate\Http\Request;
  6. /**
  7. *
  8. * 数据统计,多个数字,竖向
  9. */
  10. class NumberS extends Card
  11. {
  12. protected $height = 140;
  13. protected $title = 'Number';
  14. public function __construct()
  15. {
  16. if ($options = $this->defaultChartOptions()) {
  17. $this->chartOptions = $options;
  18. }
  19. $this->init();
  20. }
  21. /**
  22. * 处理请求
  23. *
  24. * @param Request $request
  25. *
  26. * @return mixed|void
  27. */
  28. public function handle(Request $request)
  29. {
  30. $this->withContent(162);
  31. }
  32. /**
  33. * 卡片内容
  34. *
  35. * @param string $contents 键值对 title=>number
  36. *
  37. * @return $this
  38. */
  39. public function withContent(array $contents)
  40. {
  41. $string = '';
  42. foreach ($contents as $title => $number) {
  43. $c = new Number($title);
  44. $c->withContent($number);
  45. // $string .= <<<HTML
  46. //<div class="d-flex flex-column flex-wrap text-center">
  47. // <h1 class="font-lg-2 mt-2 mb-0">{$content}</h1>
  48. //</div>
  49. //HTML;
  50. $string.= $c->render();
  51. }
  52. return $this->content($string);
  53. }
  54. }