Beispiel #1
0
 /**
  * Create a new Binding for the dashboard.
  *
  * @param  mixed $arg1 One or array of many ControlWrappers
  * @param  mixed $arg2 One or array of many ChartWrappers
  * @throws \Khill\Lavacharts\Exceptions\InvalidBindings
  * @return \Khill\Lavacharts\Dashboards\Bindings\Binding
  */
 public static function create($arg1, $arg2)
 {
     $chartWrapperArrayCheck = Utils::arrayValuesCheck($arg2, 'class', 'ChartWrapper');
     $controlWrapperArrayCheck = Utils::arrayValuesCheck($arg1, 'class', 'ControlWrapper');
     if ($arg1 instanceof ControlWrapper && $arg2 instanceof ChartWrapper) {
         return new OneToOne($arg1, $arg2);
     } elseif ($arg1 instanceof ControlWrapper && $chartWrapperArrayCheck) {
         return new OneToMany($arg1, $arg2);
     } elseif ($controlWrapperArrayCheck && $arg2 instanceof ChartWrapper) {
         return new ManyToOne($arg1, $arg2);
     } elseif ($controlWrapperArrayCheck && $chartWrapperArrayCheck) {
         return new ManyToMany($arg1, $arg2);
     } else {
         throw new InvalidBindings();
     }
 }
 /**
  * The colors to use for the chart elements.
  *
  * An array of strings, where each element is an HTML color string
  * for example:['red','#004411']
  *
  *
  * @access public
  * @param  array $colorArray
  * @return \Khill\Lavacharts\Charts\Chart
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  */
 public function colors($colorArray)
 {
     if (Utils::arrayValuesCheck($colorArray, 'string') === false) {
         throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'with valid HTML colors');
     }
     return $this->setOption(__FUNCTION__, $colorArray);
 }
Beispiel #3
0
 /**
  * Specifies properties for individual vertical axes
  *
  * If the chart has multiple vertical axes. Each child object is a vAxis object,
  * and can contain all the properties supported by vAxis.
  * These property values override any global settings for the same property.
  *
  * To specify a chart with multiple vertical axes, first define a new axis using
  * series.targetAxisIndex, then configure the axis using vAxes.
  *
  * @param  array              $a Array of VerticalAxis objects
  * @throws InvalidConfigValue
  *
  * @return AreaChart
  */
 public function vAxes($a)
 {
     if (Utils::arrayValuesCheck($a, 'class', 'VerticalAxis')) {
         return $this->addOption(array(__FUNCTION__ => $a));
     } else {
         throw $this->invalidConfigValue(__FUNCTION__, 'array', 'of VerticalAxis Objects');
     }
 }
 /**
  * Supplemental function to add columns from an array.
  *
  * @param  array                   $colDefArray
  * @throws InvalidColumnDefinition
  * @return DataTable
  */
 private function addColumnFromArray($colDefArray)
 {
     if (Utils::arrayValuesCheck($colDefArray, 'string') && Utils::between(1, count($colDefArray), 4, true)) {
         call_user_func_array(array($this, 'addColumnFromStrings'), $colDefArray);
     } else {
         throw new InvalidColumnDefinition($colDefArray);
     }
     return $this;
 }
Beispiel #5
0
 /**
  * The colors to use for the chart elements. An array of strings, where each
  * element is an HTML color string, for example: colors:['red','#004411'].
  *
  * @param  array              $cArr
  * @throws InvalidConfigValue
  *
  * @return Chart
  */
 public function colors($cArr)
 {
     if (Utils::arrayValuesCheck($cArr, 'string')) {
         return $this->addOption(array(__FUNCTION__ => $cArr));
     } else {
         throw $this->invalidConfigValue(__FUNCTION__, 'array', 'with valid HTML colors');
     }
 }
Beispiel #6
0
 /**
  * Colors to assign to values in the visualization. An array of strings,
  * where each element is an HTML color string.
  *
  * For example: ['red', '#004411']
  * You must have at least two values; the gradient will include all your
  * values, plus calculated intermediary values, with the first color as the
  * smallest value, and the last color as the highest.
  *
  * @param  array $colors
  * @return \Khill\Lavacharts\Configs\ColorAxis
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  */
 public function colors($colors)
 {
     if (is_array($colors) === false || count($colors) <= 1 || Utils::arrayValuesCheck($colors, 'string') === false) {
         throw new InvalidConfigValue(__FUNCTION__, 'array', 'with a minimum of two strings representing html colors.');
     }
     return $this->setOption(__FUNCTION__, $colors);
 }
 /**
  * @dataProvider badParamsProvider
  */
 public function testArrayValuesCheckWithBadParams($badData, $testType, $extra = '')
 {
     $this->assertFalse(Utils::arrayValuesCheck($badData, $testType, $extra));
 }
Beispiel #8
0
 /**
  * Sets the format of multiple columns.
  *
  * @access public
  * @param  array $colFormatArr
  * @return \Khill\Lavacharts\DataTables\DataTable
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  */
 public function formatColumns($colFormatArr)
 {
     if (Utils::arrayValuesCheck($colFormatArr, 'class', 'Format') === false) {
         throw new InvalidConfigValue('DataTable->' . __FUNCTION__, 'array', 'Where the keys are column indices and the values Format objects');
     }
     foreach ($colFormatArr as $index => $format) {
         $this->formatColumn($index, $format);
     }
     return $this;
 }
Beispiel #9
0
 /**
  * Many styles of dashed lines are possible via the lineDashStyle option, which takes an array of numbers.
  *
  * The first number indicates the length of a dash, and the second indicates the gap after it.
  * If there is a third number, that's the length of the next dash, and a fourth number, if present,
  * is the length of the next gap.
  *
  * When the chart is drawn, these lengths are repeated, so [4, 4] means a succession of 4-length dashes
  * and 4-length gaps. [5, 1, 3] means a 5-length dash, a 1-length gap, a 3-length dash, a 5-length gap, and so on.
  *
  *
  * @param array $lineDashStyle
  * @return \Khill\Lavacharts\Configs\Series
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  */
 public function lineDashStyle($lineDashStyle)
 {
     if (Utils::arrayValuesCheck($lineDashStyle, 'int') === false) {
         throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'of integers');
     }
     return $this->setOption(__FUNCTION__, $lineDashStyle);
 }
Beispiel #10
0
 /**
  * Colors to assign to values in the visualization. An array of strings,
  * where each element is an HTML color string.
  *
  * For example: $this->colors = array('red', '#004411')
  * You must have at least two values; the gradient will include all your
  * values, plus calculated intermediary values, with the first color as the
  * smallest value, and the last color as the highest.
  *
  * @param  array              $colors
  * @throws InvalidConfigValue
  * @return ColorAxis
  */
 public function colors($colors)
 {
     if (is_array($colors) && Utils::arrayValuesCheck($colors, 'string') && count($colors) > 1) {
         $this->colors = $colors;
     } else {
         throw new InvalidConfigValue(__FUNCTION__, 'array', 'minimum of two, with values as html color strings');
     }
     return $this;
 }