Overview
Comment:Only show details for first 95% in pie charts, enable percentage
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev | 1.0.0-alpha6
Files: files | file ages | folders
SHA1: 9efb5b3b6726eed5a5ecfc984488e8cd38fffad7
User & Date: bohwaz on 2020-11-10 04:34:50
Other Links: branch diff | manifest | tags
Context
2020-11-10
04:49
Improve label truncate in pie graph check-in: 06a302654e user: bohwaz tags: dev
04:34
Only show details for first 95% in pie charts, enable percentage check-in: 9efb5b3b67 user: bohwaz tags: dev, 1.0.0-alpha6
03:04
Improve graph labels check-in: c3823b9a01 user: bohwaz tags: dev, 1.0.0-alpha6
Changes

Modified src/include/lib/Garradin/Accounting/Graph.php from [ad6f7a4521] to [8035d9b7a3].

129
130
131
132
133
134
135


136





137
138
139
140
141
142
143
144
145
146
147


148
149
150
151
152
153


154
155
156
157
158
159
160

		$pie_criterias = self::PIE_TYPES[$type];
		$data = Reports::getClosingSumsWithAccounts(array_merge($criterias, $pie_criterias), 'ABS(sum) DESC');

		$others = 0;
		$colors = self::getColors();
		$max = count($colors);


		$i = 0;






		foreach ($data as $row)
		{
			if ($i++ >= $max)
			{
				$others += $row->sum;
			}
			else
			{
				$pie->add(new Pie_Data(abs($row->sum) / 100, substr($row->label, 0, 50), $colors[$i-1]));
			}


		}

		if ($others != 0)
		{
			$pie->add(new Pie_Data(abs($others) / 100, 'Autres', '#ccc'));
		}



		return $pie->output();
	}

	static protected function getColors()
	{
		$config = Config::getInstance();







>
>

>
>
>
>
>



|







>
>






>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

		$pie_criterias = self::PIE_TYPES[$type];
		$data = Reports::getClosingSumsWithAccounts(array_merge($criterias, $pie_criterias), 'ABS(sum) DESC');

		$others = 0;
		$colors = self::getColors();
		$max = count($colors);
		$total = 0;
		$count = 0;
		$i = 0;

		foreach ($data as $row) {
			$row->sum = abs($row->sum);
			$total += $row->sum;
		}

		foreach ($data as $row)
		{
			if ($i++ >= $max || $count > $total*0.95)
			{
				$others += $row->sum;
			}
			else
			{
				$pie->add(new Pie_Data(abs($row->sum) / 100, substr($row->label, 0, 50), $colors[$i-1]));
			}

			$count += $row->sum;
		}

		if ($others != 0)
		{
			$pie->add(new Pie_Data(abs($others) / 100, 'Autres', '#ccc'));
		}

		$pie->togglePercentage(true);

		return $pie->output();
	}

	static protected function getColors()
	{
		$config = Config::getInstance();