Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
ChartWidget.php
1 <?php
2 
3 
4 /**
5  *
6  **/
7 class ChartWidget extends CWidget
8 {
9  /**
10  * Maximum chart width
11  *
12  * @public int
13  **/
14  public $width = 200;
15 
16  /**
17  * Chart title
18  *
19  * @public string
20  **/
21  public $title;
22 
23  /**
24  * Format array('title' => 'Population', 'value' => '299.2')
25  *
26  * @public string
27  **/
28  public $rows = array();
29 
30  /**
31  * Units of measurment
32  *
33  * @public string
34  **/
35  public $units;
36 
37  public function run()
38  {
39  $maxValue = ~PHP_INT_MAX;
40  foreach($this->rows as $row)
41  {
42  $maxValue = max($maxValue, $row['value']);
43  }
44  foreach($this->rows as &$row)
45  {
46  $row['width'] = $maxValue == 0 ? 0 : (($this->width / $maxValue) * $row['value']);
47  }
48  $this->render('ChartWidget');
49  }
50 
51 }