Bar.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Dcat\Admin\Widgets\Chart;
  3. /**
  4. * @see https://www.chartjs.org/docs/latest/charts/bar.html
  5. */
  6. class Bar extends Chart
  7. {
  8. use ScaleSetting;
  9. protected $type = 'bar';
  10. /**
  11. * Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other.
  12. *
  13. * @param number $val default 0.9
  14. *
  15. * @return $this
  16. */
  17. public function barPercentage($val)
  18. {
  19. return $this->options(['barPercentage' => $val]);
  20. }
  21. /**
  22. * Percent (0-1) of the available width each category should be within the sample width.
  23. *
  24. * @param number $val default 0.8
  25. *
  26. * @return $this
  27. */
  28. public function categoryPercentage($val)
  29. {
  30. return $this->options(['categoryPercentage' => $val]);
  31. }
  32. public function barThickness($val)
  33. {
  34. return $this->options(['barThickness' => $val]);
  35. }
  36. public function maxBarThickness($val)
  37. {
  38. return $this->options(['maxBarThickness' => $val]);
  39. }
  40. public function minBarLength($val)
  41. {
  42. return $this->options(['minBarLength' => $val]);
  43. }
  44. }