Created
October 25, 2013 17:00
-
-
Save hugofabricio/7158053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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