<?php
namespace Ceetrox\Sidekick\Views\Limitless\Linechart\ChartManager;

class SeriesData
{
    private $name;
    private $categoryValues;
    private $index;
    private $type;
    private $stackName;
    private $showPointValues;
    private $isArea;
    private $markLine;

    public function __construct()
    {
        $this->categoryValues = [];
        $this->index = 0;
        $this->type = null;
        $this->stackName = null;
        $this->showPointValues = null;
        $this->isArea = null;
        $this->markLine = null;
    }

    public function getIndex() : int
    {
        return $this->index;
    }

    private function getName() : string
    {
        return $this->name;
    }

    private function getCategoryValues() : array
    {
        return $this->categoryValues;
    }


    private function getType() : ?string
    {
        return $this->type;
    }

    private function getStackName() : ?string
    {
        return $this->stackName;
    }

    private function getShowPointValues() : ?bool
    {
        return $this->showPointValues;
    }

    private function getIsArea() : ?bool
    {
        return $this->isArea;
    }

    private function getMarkLine() : ?string
    {
        return $this->markLine;
    }

    public function setName(string $name) : SeriesData
    {
        $this->name = $name;
        return $this;
    }

    public function setCategoryValues($values) : SeriesData
    {
        if(is_array($values)) {
            $this->categoryValues = array_merge($this->categoryValues, $values);
        } else {
            $this->categoryValues[] = $values;
        }

        return $this;
    }

    public function setIndex(int $index) : SeriesData
    {
        $this->index = $index;
        return $this;
    }

    public function setType(string $value) : SeriesData
    {
        $this->type = $value;
        return $this;
    }

    public function setStackName(string $value) : SeriesData
    {
        $this->stackName = $value;
        return $this;
    }

    public function setShowPointValues(bool $value) : SeriesData
    {
        $this->showPointValues = $value;
        return $this;
    }

    public function setIsArea(bool $value) : SeriesData
    {
        $this->isArea = $value;
        return $this;
    }

    public function setMarkLine(string $value) : SeriesData
    {
        $this->markLine = $value;
        return $this;
    }

    public function toArray(): array
    {
        $data = [];

        $data['name']  = $this->getName();
        $data['data']  = $this->getCategoryValues();
        $data['index'] = $this->getIndex();

        if(!is_null($this->type)) $data['type']                     = $this->getType();
        if(!is_null($this->stackName)) $data['stacked']             = $this->getStackName();
        if(!is_null($this->showPointValues)) $data['pointValues']   = $this->getShowPointValues();
        if(!is_null($this->markLine)) $data['markLine']             = $this->getMarkLine();
        if(!is_null($this->isArea)) $data['isArea']                 = $this->getIsArea();

        return $data;
    }

}
