Привет, я использую плагин Google Charts для своего приложения CakePHP.CakePhp и плагин Google Charts
В моем контроллере я: Есть две функции, которые возвращают два графика.
function statistics() {
$this->timePerClient();
$this->timePerProjectChart();
}
ФУНКЦИЯ timePerProject
function timePerProjectChart() {
$totalProjeto = $this->timePerProject();
$tempoTotalGasto = $this->tempoTotalInvestido();
//Setup data for chart
$timePerProjectChart = new GoogleChart();
$timePerProjectChart->type("PieChart");
$timePerProjectChart->options(array('title' => "Percentagem de Tempo (horas) investido por Projeto"));
$timePerProjectChart->columns(array(
//Each column key should correspond to a field in your data array
'projects' => array(
'type' => 'string',
'label' => 'Projeto'
),
'tempoGasto' => array(
'type' => 'time',
'label' => '% horas'
)
));
//You can also use this way to loop through data and creates data rows:
foreach ($totalProjeto as $row) {
$percentagemTempoGasto = ($this->timeToHour($row[0]['tempogasto'])/$tempoTotalGasto[0][0]['tempogasto']) * 100;
$timePerProjectChart->addRow(array('tempoGasto' => $percentagemTempoGasto, 'projects' => $row['Project']['pname']));
}
//Set the chart for your view
$this->set('timePerProjectChart', $timePerProjectChart);
}
С моей точки зрения (статистика) я сделать:
<div id="chart_div" ><?php $this->GoogleChart->createJsChart($timePerProjectChart);
$this->GoogleChart->createJsChart($timePerClientChart);
?></div>
, но я просто не могу видеть один график. Я тестировал (индивидуально) каждый и функционировал. Я хочу разместить несколько диаграмм на одном и том же представлении.
Возможно ли это?
thanks
Какой плагин вы используете? Это он? https://github.com/segy/GoogleChart У этого нет метода createJSChart – swiecki
Я использую это: https://github.com/scottharwell/cakephp-googlecharts-plugin – Jcbo
в порядке, в этом случае ваш код выглядит хорошо , – swiecki