Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Pie.php « Chart « Visualization « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6fd6ff8ef9f2a8b3a07f737b4ee3bc0f7997533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 * @version $Id$
 *
 * @category Piwik
 * @package Piwik
 */

/**
 * Customize & set values for the Flash Pie chart
 *
 * @package Piwik
 * @subpackage Piwik_Visualization
 */
class Piwik_Visualization_Chart_Pie extends Piwik_Visualization_Chart
{
	
	protected $seriesColors = array('#59727F', '#7DAAC0', '#7F7259', '#C09E7D', '#9BB39B',
			'#B1D8B3', '#B39BA7', '#D8B1C5', '#A5A5A5');
	
	function customizeChartProperties()
	{
		if (count($this->data) == 0)
		{
			return;
		}
		
		// make sure we only have one series
		$series = &$this->series[0];
		$this->series = array(&$series);
		
		$data = &$this->data[0];
		$this->data = array(&$data);
		
		// we never plot empty pie slices (eg. visits by server time pie chart)
		foreach ($data as $i => $value)
		{
			if ($value <= 0)
			{
				unset($data[$i]);
				unset($this->axes['xaxis']['ticks'][$i]);
			}
		}
		$data = array_values($data);
		$this->axes['xaxis']['ticks'] = array_values($this->axes['xaxis']['ticks']);
		
		// prepare percentages for tooltip
		$sum = array_sum($data);
		foreach ($data as $i => $value)
		{
			$value = (float) $value;
			$this->tooltip['percentages'][0][$i] = round(100 * $value / $sum);
		}
	}
}