本文整理汇总了PHP中Khill\Lavacharts\Utils::isIntOrPercent方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::isIntOrPercent方法的具体用法?PHP Utils::isIntOrPercent怎么用?PHP Utils::isIntOrPercent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Khill\Lavacharts\Utils
的用法示例。
在下文中一共展示了Utils::isIntOrPercent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: barGroupWidth
/**
* 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]);
}
示例2: barGroupWidth
/**
* 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;
}
示例3: height
/**
* 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;
}
示例4: testIntOrPercentWithBadParams
/**
* @dataProvider badParamsProvider
*/
public function testIntOrPercentWithBadParams($value)
{
$this->assertFalse(Utils::isIntOrPercent($value));
}
示例5: setIntOrPercentOption
/**
* 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;
}