From 09f8b354f7733fc7e7c22aa6533ba8ca91a53b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Santib=C3=A1=C3=B1ez?= Date: Sun, 25 Oct 2020 00:49:10 -0500 Subject: [PATCH] Added more expressive api for legend config --- src/Models/HasLegend.php | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/Models/HasLegend.php b/src/Models/HasLegend.php index 447b12f..3c7399c 100644 --- a/src/Models/HasLegend.php +++ b/src/Models/HasLegend.php @@ -29,6 +29,65 @@ trait HasLegend return $this; } + public function setLegendPosition($position) + { + data_set($this->legend, 'position', $position); + + return $this; + } + + public function setLegendHorizontalAlign($horizontalAlign) + { + data_set($this->legend, 'horizontalAlign', $horizontalAlign); + + return $this; + } + + public function withoutLegend() + { + return $this->setLegendVisibility(false); + } + + public function withLegend() + { + return $this->setLegendVisibility(true); + } + + public function legendPositionTop() + { + return $this->setLegendPosition('top'); + } + + public function legendPositionLeft() + { + return $this->setLegendPosition('left'); + } + + public function legendPositionRight() + { + return $this->setLegendPosition('right'); + } + + public function legendPositionBottom() + { + return $this->setLegendPosition('bottom'); + } + + public function legendHorizontallyAlignedLeft() + { + return $this->setLegendHorizontalAlign('left'); + } + + public function legendHorizontallyAlignedCenter() + { + return $this->setLegendHorizontalAlign('center'); + } + + public function legendHorizontallyAlignedRight() + { + return $this->setLegendHorizontalAlign('right'); + } + protected function legendToArray() { return [