/** * @param ChartQuery $query * @return string */ public function renderChartQuery(ChartQuery $query) { if (Query::ACTION_GET !== $query->getAction()) { throw new \RuntimeException('NumerologChart only accepts the Numerolog `get` command'); } $client = $this->getNumerologClient(); $response = $client->query($query); $chartType = $query->getChartType(); $chartLabel = $query->getChartLabel(); $chartTitle = $chartLabel . ': ' . $query->getCounter(); $chartAttributes = $query->getChartAttributes(); $table = $this->fillWithResponseData($response['values'], $query); $chart = $this->{$chartType}($chartLabel)->title($chartTitle); if (!empty($chartAttributes)) { $chart->setOptions($chartAttributes); } $chart->datatable($table); if ($query->getScriptOnly()) { return $this->render($chartType, $chartLabel, $query->getChartId()); } return $this->render($chartType, $chartLabel, $query->getChartId(), array('width' => $query->getChartWidth(), 'height' => $query->getChartHeight())); }