本文整理汇总了PHP中Khill\Lavacharts\Utils类的典型用法代码示例。如果您正苦于以下问题:PHP Utils类的具体用法?PHP Utils怎么用?PHP Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOption
/**
* Overriding getOption function to pull config options from calendar array.
* (Thanks google)
*
* @param string $o Which option to fetch
* @throws InvalidConfigValue
* @return mixed
*/
public function getOption($o)
{
if (is_string($o) && array_key_exists($o, $this->options['calendar'])) {
return $this->options['calendar'][$o];
} else {
if (is_string($o) && array_key_exists($o, $this->options)) {
return $this->options[$o];
} else {
$calendarOptions = $this->options['calendar'];
$nonCalendarOptions = array_diff($this->options, $calendarOptions);
$options = array_merge($calendarOptions, $nonCalendarOptions);
throw $this->invalidConfigValue(__FUNCTION__, 'string', 'must be one of ' . Utils::arrayToPipedString(array_keys($options)));
}
}
}
示例2: strokeOpacity
/**
* Sets the opacity of the stroke.
*
* @param float $strokeOpacity
* @return \Khill\Lavacharts\Configs\Stroke
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
*/
public function strokeOpacity($strokeOpacity)
{
if (Utils::between(0.0, $strokeOpacity, 1.0, true) === false) {
throw new InvalidConfigValue(__FUNCTION__, 'float', 'between 0.0 and 1.0');
}
return $this->setOption(__FUNCTION__, $strokeOpacity);
}
示例3: offset
/**
* How far to separate the slice from the rest of the pie.
* from 0.0 (not at all) to 1.0 (the pie's radius).
*
* @param float $offset
* @return \Khill\Lavacharts\Configs\Slice
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
*/
public function offset($offset)
{
if (Utils::between(0.0, $offset, 1.0) === false) {
throw new InvalidConfigValue(__FUNCTION__, 'float', 'where 0.0 < $offset < 1.0');
}
return $this->setOption(__FUNCTION__, $offset);
}
示例4: opacity
/**
* Sets the transparency of assigned object points
*
* 1.0 being completely opaque and 0.0 fully transparent.
*
* @param float $opacity
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
* @return \Khill\Lavacharts\Charts\Chart
*/
public function opacity($opacity)
{
if (Utils::between(0.0, $opacity, 1.0) === false) {
throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'float', 'between 0.0 - 1.0');
}
return $this->setOption(__FUNCTION__, $opacity);
}
示例5: 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]);
}
示例6: pieHole
/**
* If between 0 and 1, displays a donut chart.
*
* The hole with have a radius equal to $pieHole times the radius of the chart.
*
*
* @param integer|float $pieHole Size of the pie hole.
* @return \Khill\Lavacharts\Charts\DonutChart
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
*/
public function pieHole($pieHole)
{
if (Utils::between(0.0, $pieHole, 1.0) === false) {
throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'float', 'while, 0 < pieHole < 1 ');
}
return $this->setOption(__FUNCTION__, $pieHole);
}
示例7: set
/**
* Sets the callback for an event.
*
* @access public
* @param string $event
* @param string $callback
* @throws \Khill\Lavacharts\Exceptions\InvalidEvent
* @throws \Khill\Lavacharts\Exceptions\InvalidEventCallback
*/
public function set($event, $callback)
{
$this->validEvent($event);
if (Utils::nonEmptyString($callback) === false) {
throw new InvalidEventCallback($callback);
}
$this->events[$event] = $callback;
}
示例8: __construct
/**
* Builds the Event object.
*
* @param string $c Name of Javascript callback function.
* @throws InvalidConfigValue
* @return Event
*/
public function __construct($c)
{
if (Utils::nonEmptyString($c)) {
$this->callback = $c;
} else {
throw new InvalidConfigValue('an Event', 'string');
}
}
示例9: offset
/**
* How far to separate the slice from the rest of the pie.
* from 0.0 (not at all) to 1.0 (the pie's radius).
*
* @param float $offset
* @throws InvalidConfigValue
* @return Slice
*/
public function offset($offset)
{
if (Utils::between(0.0, $offset, 1.0)) {
$this->offset = $offset;
} else {
throw new InvalidConfigValue(__FUNCTION__, 'float', 'where 0.0 < $offset < 0.1');
}
return $this;
}
示例10: 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 ColumnChart
*/
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;
}
示例11: strokeOpacity
/**
* Sets the opacity of the stroke.
*
* @param float $strokeOpacity
* @throws InvalidConfigValue
* @return Stroke
*/
public function strokeOpacity($so)
{
if (Utils::between(0.0, $so, 1.0, true)) {
$this->strokeOpacity = (double) $so;
} else {
throw new InvalidConfigValue(__FUNCTION__, 'float');
}
return $this;
}
示例12: pieHole
/**
* If between 0 and 1, displays a donut chart. The hole with have a radius
* equal to $pieHole times the radius of the chart.
*
* @param int|float $pieHole
*
* @return DonutChart
*/
public function pieHole($pieHole)
{
if (Utils::between(0.0, $pieHole, 1.0)) {
$this->addOption(array('pieHole' => $pieHole));
} else {
throw $this->invalidConfigValue(__FUNCTION__, 'float', 'while, 0 < pieHole < 1 ');
}
return $this;
}
示例13: matchType
/**
* The method of filtering the string:
*
* exact - The pattern matches the string exactly.
* prefix - The pattern is found at the beginning of the string.
* any - The pattern is found anywhere in the string.
*
* @param string $position
* @throws InvalidConfigValue
* @return StringFilter
*/
public function matchType($type)
{
$values = array('exact', 'prefix', 'any');
if (is_string($type) && in_array($type, $values)) {
$this->addOption(array(__FUNCTION__ => $type));
} else {
throw $this->invalidConfigValue(__FUNCTION__, 'string', 'with a value of ' . Utils::arrayToPipedString($values));
}
return $this;
}
示例14: curveType
/**
* Controls the curve of the lines when the line width is not zero.
*
* Can be one of the following:
* 'none' - Straight lines without curve.
* 'function' - The angles of the line will be smoothed.
*
* @param string $curveType
* @throws InvalidConfigValue
* @return LineChart
*/
public function curveType($curveType)
{
$values = array('none', 'function');
if (is_string($curveType) && in_array($curveType, $values)) {
$this->addOption(array('curveType' => $curveType));
} else {
throw $this->invalidConfigValue(__FUNCTION__, 'string', 'with a value of ' . Utils::arrayToPipedString($values));
}
return $this;
}
示例15: axisTitlesPosition
/**
* Where to place the axis titles, compared to the chart area. Supported values:
*
* in - Draw the axis titles inside the the chart area.
* out - Draw the axis titles outside the chart area.
* none - Omit the axis titles.
*
* @param string $position
* @throws InvalidConfigValue
* @return AreaChart
*/
public function axisTitlesPosition($position)
{
$values = array('in', 'out', 'none');
if (is_string($position) && in_array($position, $values)) {
$this->addOption(array('axisTitlesPosition' => $position));
} else {
throw $this->invalidConfigValue(__FUNCTION__, 'string', 'with a value of ' . Utils::arrayToPipedString($values));
}
return $this;
}