/** * Defines how the chart trendlines will be displayed. * * @param array $trendlineConfigArray * @return \Khill\Lavacharts\Charts\Chart * @throws \Khill\Lavacharts\Traits\InvalidConfigValue */ public function trendlines($trendlineConfigArray) { if (Utils::arrayIsMulti($trendlineConfigArray) === false) { throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'With arrays of Trendline options.'); } $trendlines = []; foreach ($trendlineConfigArray as $index => $trendlineConfig) { $trendlines[(string) $index] = new Trendline($trendlineConfig); } return $this->setOption(__FUNCTION__, $trendlines); }
/** * Specifies properties for individual horizontal axes, if the chart has multiple horizontal axes. * Each child object is a hAxis object, and can contain all the properties supported by hAxis. * These property values override any global settings for the same property. * To specify a chart with multiple horizontal axes, first define a new axis using series.targetAxisIndex, * then configure the axis using hAxes. * * @param array $hAxisConfigArray Array of HorizontalAxis configuration arrays * @return \Khill\Lavacharts\Charts\Chart * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue */ public function hAxes($hAxisConfigArray) { if (Utils::arrayIsMulti($hAxisConfigArray) === false) { throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'With arrays of HorizontalAxis options.'); } $hAxes = []; foreach ($hAxisConfigArray as $hAxisConfig) { $hAxes[] = new HorizontalAxis($hAxisConfig); } return $this->setOption(__FUNCTION__, $hAxes); }
/** * An array of objects, each describing the format of the corresponding series * in the chart. * To use default values for a series, specify an null in the array. * If a series or a value is not specified, the global value will be used. * * @param array $seriesConfigArray Array of Series options. * @return \Khill\Lavacharts\Charts\Chart * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue */ public function series($seriesConfigArray) { if (Utils::arrayIsMulti($seriesConfigArray) === false) { throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'With arrays of Series options.'); } $series = []; foreach ($seriesConfigArray as $seriesConfig) { $series[] = new Series($seriesConfig); } return $this->setOption(__FUNCTION__, $series); }
/** * An array of slice objects, each describing the format of the * corresponding slice in the pie. * * To use default values for a slice, specify a null. If a slice or a value is not specified, * the global value will be used. * * The values of the array keys will correspond to each numbered piece * of the pie, starting from 0. You can skip slices by assigning the * keys of the array as (int)s. * * * @param array $slices Array of slice objects * @return \Khill\Lavacharts\Charts\PieChart * @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue */ public function slices($slices) { if (Utils::arrayIsMulti($slices) === false) { throw new InvalidConfigValue(static::TYPE . '->' . __FUNCTION__, 'array', 'as (int) => (Slice)'); } $pie = []; foreach ($slices as $index => $slice) { $pie[$index] = $slice; } return $this->setOption(__FUNCTION__, $pie); }
/** * Adds multiple rows to the DataTable. * * @see addRow() * @param array Multi-dimensional array of rows. * * @return DataTable */ public function addRows($arrayOfRows) { if (Utils::arrayIsMulti($arrayOfRows)) { foreach ($arrayOfRows as $row) { $this->addRow($row); } } else { throw new InvalidConfigValue(__FUNCTION__, 'array of arrays'); } return $this; }
/** * Binds controls to the dashobard. * * Takes an array of with key value pairs of $controlType=>$controlLabels, * where $controlLabels is an array of the control labels for each type of control. * * ex. * $controls = ['NumberRangeFilter|StocksOfficialFilter' => ['GoogleTable|StocksTable', 'LineChart|Stocks'] ]; * alternatively accepted when only one control for a control type: * $bindings = ['NumberRangeFilter|StocksOfficialFilter' => 'GoogleTable|StocksTable' ]; * * @param array $controls * @throws InvalidConfigProperty * @throws InvalidConfigValue * @return null */ public function bindings($bindings) { if (Utils::arrayIsMulti($bindings)) { foreach ($bindings as $control => $charts) { //or $chart=>controls if (is_array($charts) && count($charts) > 0) { foreach ($charts as $chartKey => $chart) { $chartLabel = is_int($chartKey) ? $chart : $chartKey; if ($this->checkBindingOrdering($control)) { $this->makeBinding($control, $chartLabel); } else { //Flipped ordering of [fliter=>chart(s)] to [chart=>filter(s)] $this->makeBinding($chartLabel, $control); } } } else { if (is_string($charts) && count($charts) > 0) { if ($this->checkBindingOrdering($control)) { $this->makeBinding($control, $charts); } else { $this->makeBinding($chartLabel, $control); } } else { throw $this->invalidConfigValue(__FUNCTION__, 'array | string'); } } } } else { throw $this->invalidConfigValue(__FUNCTION__, 'array'); } }
/** * @dataProvider nonArrayProvider */ public function testArrayIsMultiWithNonArray($notArray) { $this->assertFalse(Utils::arrayIsMulti($notArray)); }