/**
  * The width of a group of bars, specified in either of these formats:
  * - Pixels (e.g. 50).
  * - Percentage of the available width for each group (e.g. '20%'),
  *   where '100%' means that groups have no space between them.
  *
  * @param  int|string $barGroupWidth
  * @return \Khill\Lavacharts\Charts\Chart
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  */
 public function barGroupWidth($barGroupWidth)
 {
     if (Utils::isIntOrPercent($barGroupWidth) === false) {
         throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'int|string', 'String only if representing a percent. "50%"');
     }
     return $this->setOption(__FUNCTION__, ['groupWidth' => $barGroupWidth]);
 }
Beispiel #2
0
 /**
  * The width of a group of bars, specified in either of these formats:
  * - Pixels (e.g. 50).
  * - Percentage of the available width for each group (e.g. '20%'),
  *   where '100%' means that groups have no space between them.
  *
  * @param  mixed       $barGroupWidth
  * @return BarChart
  */
 public function barGroupWidth($barGroupWidth)
 {
     if (Utils::isIntOrPercent($barGroupWidth)) {
         $this->addOption(array('bar' => array('groupWidth' => $barGroupWidth)));
     } else {
         throw $this->invalidConfigValue(__FUNCTION__, 'string | int', 'must be a valid int or percent [ 50 | 65% ]');
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Sets the height of the chart in the container.
  *
  * @param  int                $height Amount in pixels
  * @throws InvalidConfigValue
  * @return ChartArea
  */
 public function height($height)
 {
     if (Utils::isIntOrPercent($height)) {
         $this->height = $height;
     } else {
         throw new InvalidConfigValue(__FUNCTION__, 'int | string', 'representing pixels or a percent.');
     }
     return $this;
 }
 /**
  * @dataProvider badParamsProvider
  */
 public function testIntOrPercentWithBadParams($value)
 {
     $this->assertFalse(Utils::isIntOrPercent($value));
 }
Beispiel #5
0
 /**
  * Sets the value of an integer option.
  *
  * @param  string $option Option to set.
  * @param  int    $value Value of the option.
  * @return \Khill\Lavacharts\JsonConfig
  * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
  * @throws \Khill\Lavacharts\Exceptions\InvalidOption
  */
 protected function setIntOrPercentOption($option, $value)
 {
     if (Utils::isIntOrPercent($value) === false) {
         throw new InvalidConfigValue(static::TYPE . '->' . $option, 'int|string', 'String only if representing a percent. "50%"');
     }
     $this->options->set($option, $value);
     return $this;
 }