示例#1
0
 /**
  * Add a data serie to the chart.
  *
  * @param $data (GoogleChartData)
  * @see GoogleChartData
  */
 public function addData(GoogleChartData $data)
 {
     if ($data->hasIndex()) {
         throw new LogicException('Invalid data serie. This data serie has already been added.');
     }
     $index = array_push($this->data, $data);
     $data->setIndex($index - 1);
     return $this;
 }
示例#2
0
 /**
  * Add a data serie to the chart.
  *
  * @param $data (GoogleChartData|array) If $data is an array, a default
  * instance of GoogleChartData will be create. That is a useful shortchut,
  * but doesn't allow for customization.
  *
  * @see GoogleChartData
  */
 public function addData($data)
 {
     if (is_array($data)) {
         $data = new GoogleChartData($data);
     } elseif (!$data instanceof GoogleChartData) {
         throw new InvalidArgumentException('Invalid data (must be an instance of GoogleChartData or an array).');
     }
     if ($data->hasIndex()) {
         throw new LogicException('Invalid data series. This data series has already been added.');
     }
     $index = array_push($this->data, $data);
     $data->setIndex($index - 1);
     return $this;
 }