| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <?php
- namespace ThurData\Servers\KerioEmail\Core\UI\Widget\Graphs\Models;
- /**
- * Description of ChartData
- *
- * @autor ThurData <info@thurdata.ch>
- */
- class DataSet
- {
- const POINT_STYLE_CIRCLE = 'circle';
- const POINT_STYLE_CROSS_ROT = 'crossRot';
- const POINT_STYLE_DASH = 'dash';
- const POINT_STYLE_LINE = 'line';
- const POINT_STYLE_RECT = 'rect';
- const POINT_STYLE_RECT_ROUNDED = 'rectRounded';
- const POINT_STYLE_RECT_ROT = 'rectRot';
- const POINT_STYLE_STAR = 'star';
- const POINT_STYLE_TRIANGLE = 'triangle';
-
- const STEPPED_LINE_FALSE = false;
- const STEPPED_LINE_TRUE = false;
- const STEPPED_LINE_BEFORE = 'before';
- const STEPPED_LINE_AFTER = 'after';
- protected $label = null;
- protected $type = null;
-
- /**
- * @var double[]|integer[]|array
- */
- protected $data = [];
- /**
- * @var string[]|string
- */
- protected $backgroundColor = [];
- /**
- * @var string[]|string
- */
- protected $borderColor = [];
- /**
- * @var double[]|integer[]
- */
- protected $borderDash = [];
- /**
- * @var string[]|string[]
- */
- protected $hoverBackgroundColor = [];
- /**
- * @var string[]|string[]
- */
- protected $hoverBorderColor = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $hoverBorderWidth = [];
- /**
- * @var string[]|string
- */
- protected $pointBackgroundColor= [];
- /**
- * @var string[]|string
- */
- protected $pointBorderColor = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $pointBorderWidth = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $pointRadius = [];
- /**
- * @var string[]|string
- */
- protected $pointStyle = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $pointHitRadius = [];
- /**
- * @var string[]|string
- */
- protected $pointHoverBackgroundColor = [];
- /**
- * @var string[]|string
- */
- protected $pointHoverBorderColor = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $pointHoverBorderWidth = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $pointHoverRadius = [];
- /**
- * @var double[]|double|integer[]|integer
- */
- protected $borderWidth = [];
-
- /**
- * @var double|integer
- */
- protected $borderDashOffset = null;
- /**
- * @var string
- */
- protected $xAxisID = null;
- /**
- * @var string
- */
- protected $yAxisID = null;
- /**
- * @var string
- */
- protected $borderCapStyle = null;
- /**
- * @var string
- */
- protected $borderJoinStyle = null;
- /**
- * @var string
- */
- protected $cubicInterpolationMode = null;
- /**
- * @var boolean|string
- */
- protected $fill = null;
- /**
- * @var double|integer
- */
- protected $lineTension = null;
- /**
- * @var boolean
- */
- protected $showLine = null;
- /**
- * @var boolean
- */
- protected $spanGaps = null;
- /**
- * @var boolean|string
- */
- protected $steppedLine = false;
- /**
- * @var string
- */
- protected $borderSkipped = null;
-
- public function addDataItem($value, array $configuration = [])
- {
- $this->data[] = $value;
-
- foreach ($configuration as $key => $value)
- {
- if (property_exists($this, $key))
- {
- $this->{$key}[] = $value;
- }
- }
-
- return $this;
- }
-
- public function setConfigurationDataSet(array $configuration = [])
- {
- foreach ($configuration as $key => $value)
- {
- if (property_exists($this, $key))
- {
- $this->{$key} = $value;
- }
- }
-
- return $this;
- }
-
- /**
- * Title label in Legend
- *
- * @param string $label
- * @return $this
- */
- public function setLabel($label = '')
- {
- $this->label = $label;
-
- return $this;
- }
-
- /**
- * @param string $type
- * @return $this
- */
- public function setType($type = 'line')
- {
- $this->type = $type;
-
- return $this;
- }
-
- /**
- * @param float $borderDashOffset
- * @return $this
- */
- public function setBorderDashOffset($borderDashOffset = 0)
- {
- $this->borderDashOffset = $borderDashOffset;
-
- return $this;
- }
- /**
- *
- * @param float $borderWidth
- * @return $this
- */
- public function setBorderWidth($borderWidth = 0)
- {
- $this->borderWidth = $borderWidth;
-
- return $this;
- }
- public function setXAxisID($xAxisID = '')
- {
- $this->xAxisID = $xAxisID;
-
- return $this;
- }
- public function setYAxisID($yAxisID = '')
- {
- $this->yAxisID = $yAxisID;
-
- return $this;
- }
- public function setBorderCapStyle($borderCapStyle = '')
- {
- $this->borderCapStyle = $borderCapStyle;
-
- return $this;
- }
- public function setBorderJoinStyle($borderJoinStyle = '')
- {
- $this->borderJoinStyle = $borderJoinStyle;
-
- return $this;
- }
- public function setCubicInterpolationMode($cubicInterpolationMode = '')
- {
- $this->cubicInterpolationMode = $cubicInterpolationMode;
-
- return $this;
- }
- public function setFill($fill = '')
- {
- $this->fill = $fill;
-
- return $this;
- }
- public function setLineTension($lineTension = 0)
- {
- $this->lineTension = $lineTension;
-
- return $this;
- }
- public function setShowLine($showLine = true)
- {
- $this->showLine = $showLine;
-
- return $this;
- }
- public function setSpanGaps($spanGaps = true)
- {
- $this->spanGaps = $spanGaps;
-
- return $this;
- }
- public function setBorderSkipped($borderSkipped = true)
- {
- $this->borderSkipped = $borderSkipped;
-
- return $this;
- }
- public function setSteppedLine($steppedLine = self::STEPPED_LINE_FALSE)
- {
- if (in_array($steppedLine, [self::STEPPED_LINE_FALSE, self::STEPPED_LINE_TRUE, self::STEPPED_LINE_BEFORE, self::STEPPED_LINE_AFTER], true))
- {
- $this->steppedLine = $steppedLine;
- }
-
- return $this;
- }
-
- public function toArray()
- {
- $return = [];
-
- foreach ($this as $key => $value)
- {
- if (property_exists($this, $key) && ($value !== null && !is_array($value) || is_array($value) && count($value) > 0))
- {
- $return[$key] = $value;
- }
- }
-
- return $return;
- }
-
- public function setTitle($title = '')
- {
- $this->setLabel($title);
-
- return $this;
- }
-
- public function setData($data = [])
- {
- foreach ($data as $value)
- {
- $this->addDataItem($value, []);
- }
-
- return $this;
- }
- }
|