Skip to content

Instantly share code, notes, and snippets.

@hugofabricio
Created October 25, 2013 17:00
Show Gist options
  • Select an option

  • Save hugofabricio/7158053 to your computer and use it in GitHub Desktop.

Select an option

Save hugofabricio/7158053 to your computer and use it in GitHub Desktop.
/**
* Index
*/
public function index()
{
// Busca todas as equipes
$teams = $this->Team->find('all', array('conditions' => array('Team.is_active' => true), 'recursive' => -1));
// Istância um novo gráfico
$chart = new Highchart();
$chart->chart->renderTo = "graph";
$chart->chart->type = "column";
$chart->title->text = false;
$chart->xAxis->categories = array('Equipes');
$chart->yAxis->min = 0;
$chart->yAxis->title->text = "Tectech´s";
$chart->legend->enabled = true;
$chart->legend = array('borderWidth' => 0);
$chart->credits->enabled = false;
$chart->export->enabled = true;
$chart->tooltip->formatter = new HighchartJsExpr("function() {return '' + this.series.name + ': ' + this.y;}");
// Percorre as equipes e popula o gráfico
foreach ($teams as $result):
$chart->series[] = array(
'name' => $result['Team']['acronym'],
'data' => array((int)$result['Team']['points'])
);
$colours[] = $result['Team']['color'];
endforeach;
// Cores das equipes no gráfico
$theme = new HighchartOption();
$theme->colors = $colours;
// Set
$this->set(
array(
'title_for_layout' => 'Ranking',
'chart' => $chart,
'theme' => $theme
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment