123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace Dcat\Admin\Widgets\Chart;
- trait ScaleSetting
- {
- /**
- * @see https://www.chartjs.org/docs/latest/axes/
- *
- * @param array $opts
- *
- * @return $this
- */
- public function scales(array $opts)
- {
- if (! isset($this->options['scales'])) {
- $this->options['scales'] = [];
- }
- $this->options['scales'] = array_merge($this->options['scales'], $opts);
- return $this;
- }
- /**
- * @param string|null $label
- *
- * @return $this
- */
- public function displayScaleLabelOnX(?string $label)
- {
- return $this->xAxes([
- [
- 'scaleLabel' => [
- 'display' => true,
- 'labelString' => $label,
- ],
- ],
- ]);
- }
- /**
- * @param string|null $label
- *
- * @return $this
- */
- public function displayScaleLabelOnY(?string $label)
- {
- return $this->yAxes([
- [
- 'scaleLabel' => [
- 'display' => true,
- 'labelString' => $label,
- ],
- ],
- ]);
- }
- /**
- * @param array $opts
- *
- * @return $this
- */
- public function yAxes(array $opts)
- {
- return $this->scales(['yAxes' => $opts]);
- }
- /**
- * @param array $opts
- *
- * @return $this
- */
- public function xAxes(array $opts)
- {
- return $this->scales(['xAxes' => $opts]);
- }
- /**
- * @see https://www.chartjs.org/docs/latest/axes/radial/linear.html
- *
- * @param array $opts
- *
- * @return $this
- */
- public function scale(array $opts)
- {
- if (! isset($this->options['scale'])) {
- $this->options['scale'] = [];
- }
- $this->options['scale'] = array_merge($this->options['scale'], $opts);
- return $this;
- }
- }
|