NumberS2.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace UCore\DcatAdmin\Metrics\Examples;
  3. use Dcat\Admin\Widgets\Metrics\RadialBar;
  4. use Illuminate\Support\Str;
  5. /**
  6. * 显示多个数值
  7. * 一行
  8. */
  9. class NumberS2 extends RadialBar
  10. {
  11. protected $contentWidth = [12, 0];
  12. protected $chartPullRight =true;
  13. protected $decimal_places = 2;
  14. /**
  15. * 初始化卡片内容
  16. */
  17. protected function init()
  18. {
  19. $this->id('metric-card-'.Str::random(8));
  20. $this->class('card');
  21. $this->height(130);
  22. $this->dropdown([
  23. '1' => '最近 1 天',
  24. '7' => '最近 7 天',
  25. '30' => '最近 30 天',
  26. '90' => '最近 90 天',
  27. ]);
  28. }
  29. /**
  30. * 卡片内容.
  31. *
  32. * @param string $new
  33. * @param string $open
  34. * @param string $response
  35. *
  36. * @return $this
  37. */
  38. public function withContent($dataList )
  39. {
  40. $string = '';
  41. foreach ($dataList as $key => $value) {
  42. $value = number_format(floatval( $value), $this->decimal_places);
  43. $string .= <<<HTML
  44. <div class="text-center">
  45. <p>$key</p>
  46. <span class="font-md-5">{$value}</span>
  47. </div>
  48. HTML;
  49. }
  50. return $this->content(
  51. <<<HTML
  52. <div class="d-flex justify-content-between p-1" style="padding-top: 15px !important;">
  53. $string
  54. </div>
  55. HTML
  56. );
  57. }
  58. }