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

ChartEvolution.php « Visualization « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 82f2da4fa46be3c94aa9bd51535577a1ca627e75 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?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: ChartVerticalBar.php 168 2008-01-14 05:26:43Z matt $
 * 
 * @package Piwik_Visualization
 */

require_once "Visualization/Chart.php";

/**
 * Customize the Evolution chart style for the flash graph
 * 
 * @package Piwik_Visualization
 */
class Piwik_Visualization_ChartEvolution extends Piwik_Visualization_Chart
{
	function customizeGraph()
	{
		parent::customizeGraph();
		//$this->prepareData();

		$colors = array(
			"0x3357A0",
			"0x9933CC",
			"0xCC3399",			
			"0x80a033",
			"0xFD9816",
			"0x246AD2",
			"0xFD16EA",
			"0x49C100",
			);

		// first row in array contains line labels (legend)		
		$legendLabels = array_shift($this->dataGraph);

		$line = array();

		// define labels
		foreach($legendLabels as $nbLabel => $labelName)
		{
			$line[$nbLabel] = new line_hollow( 1, 3, $colors[$nbLabel] );
			$line[$nbLabel]->key( $labelName, 10 );
		}
		
		$maxData = 0;		
		$xLabels = array();		
		$cnt = count($this->dataGraph);
		
		// loop over data
		foreach($this->dataGraph as $values)
		{
			// add x axis value (label)
			array_push($xLabels, $values['label']);
			
			// loop over values for all lines (y axis values)		
			for($j = 0; $j < count($legendLabels); $j++)
			{
				// get the y axis value for line $j
				$dotValue = $values['value'.$j];
				
				// find maximum y axis value 
				if(  $dotValue > $maxData )
				{
					$maxData = $dotValue;
				}

				$link = null;
				if($this->isLinkEnabled())
				{
					$spacePosition = strpos($values['label'],' ');
					if($spacePosition === false)
					{
						$spacePosition = strlen($values['label']);
					}				
					$link = Piwik_Url::getCurrentScriptName() . 
							Piwik_Url::getCurrentQueryStringWithParametersModified( array(
								'date' => substr($values['label'],0,$spacePosition),
								'module' => 'CoreHome',
								'action' => 'index',
								'viewDataTable' => null// we reset the viewDataTable parameter (useless in the link)
						));
					// add the dot on the chart and link it
					$line[$j]->add_link($dotValue, $link);
				}
				else
				{
					$line[$j]->add($dotValue);
				}
			}
		}
		$this->data_sets = $line;		
		$this->set_y_max( $maxData );
		$this->set_x_labels( $xLabels );
	}
	
	private function isLinkEnabled() 
	{
		static $linkEnabled;
		if(!isset($linkEnabled)) 
		{
			$linkEnabled = !Piwik_Common::getRequestVar('disableLink', 0, 'int');
		}
		return $linkEnabled;
	}
}