NumberS.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 $title = '多行数字';
  13. public function __construct()
  14. {
  15. if ($options = $this->defaultChartOptions()) {
  16. $this->chartOptions = $options;
  17. }
  18. $this->init();
  19. }
  20. /**
  21. * 处理请求
  22. *
  23. * @param Request $request
  24. *
  25. * @return mixed|void
  26. */
  27. public function handle(Request $request)
  28. {
  29. $this->withContent([
  30. // 一个键值对,一行
  31. '统计' => 162,
  32. '近日' => 75
  33. ]);
  34. }
  35. /**
  36. * 卡片内容
  37. *
  38. * @param string $contents 键值对 title=>number
  39. *
  40. * @return $this
  41. */
  42. public function withContent(array $contents)
  43. {
  44. $string = '';
  45. foreach ($contents as $title => $number) {
  46. $c = new Number($title);
  47. $c->withContent($number);
  48. // $string .= <<<HTML
  49. //<div class="d-flex flex-column flex-wrap text-center">
  50. // <h1 class="font-lg-2 mt-2 mb-0">{$content}</h1>
  51. //</div>
  52. //HTML;
  53. $string .= $c->render();
  54. }
  55. return $this->content($string);
  56. }
  57. }